Skip to content

[Event Request] codeunit 130618 "Library - Graph Mgt" #15756

@Arthurvdv

Description

@Arthurvdv

When creating Test Automation for API's an BC-environment with Windows authentication is required. The goal here is to use a username and password for running the AL Test Suite using NavUserPassword in stead of Windows.

In the "Http Web Request Mgt." (codeunit 1297) there's a function;

procedure AddBasicAuthentication(BasicUserId: Text; BasicUserPassword: Text)
var
    Credential: DotNet NetworkCredential;
begin
    HttpWebRequest.UseDefaultCredentials(false);
    Credential := Credential.NetworkCredential;
    Credential.UserName := BasicUserId;
    Credential.Password := BasicUserPassword;
    HttpWebRequest.Credentials := Credential;
end;

So I would like a OnBefore-event on the ExecuteWebRequestAndReadResponse in the "Library - Graph Mgt" (codeunit 130618) I could pass a User and Password to the http-call;

local procedure ExecuteWebRequestAndReadResponse(var HttpWebRequestMgt: Codeunit "Http Web Request Mgt."; var TempBlob: Codeunit "Temp Blob"; var ResponseError: Text; var HttpStatusCode: DotNet HttpStatusCode; var ResponseHeaders: DotNet NameValueCollection): Boolean
var
    WebRequestHelper: Codeunit "Web Request Helper";
    WebException: DotNet WebException;
    WebExceptionResponse: DotNet HttpWebResponse;
    ResponseInStream: InStream;
    WebExceptionResponseText: Text;
    TextLine: Text;
    ServiceUrl: Text;
    LastError: Text;
    ErrorCode: Text;
    ErrorMessage: Text;
begin
    Clear(TempBlob);
    TempBlob.CreateInStream(ResponseInStream);

    ClearLastError;
    OnBeforeGetResponse(HttpWebRequestMgt); <<-- NEW EVENT
    if HttpWebRequestMgt.GetResponse(ResponseInStream, HttpStatusCode, ResponseHeaders) then
        exit(true);

    LastError := GetLastErrorText;

    ....
[IntegrationEvent(false, false)]
local procedure OnBeforeGetResponse(var HttpWebRequestMgt: Codeunit "Http Web Request Mgt.")
begin
end;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions