Describe the bug
Have used "Http Client" in one of the extension. And when this extension is triggered, getting error "Microsoft.Dynamics.Nav.Runtime.NavHttpContent Variable not initialized"
To Reproduce
Have created an extension in which i have used "HttpClient" to consume a DotNet webservice. Below are the code:
procedure GetWeb(Parameter1: Code[20];Parameter2:Code[20]);
var
HttpClient: HttpClient;
HttpResponse: HttpResponseMessage;
ResponseText: Text;
URL: Text;
HttpRequest: HttpRequestMessage;
SubFolder: Text[100];
OrderNo: Code[20];
HttpsContent: HttpContent;
HttpsHeader: HttpHeaders;
ReturnValue: ARRAY[20] OF Text[1000];
jObj: JsonObject;
json: Text;
SalesnRec: Record "Sales & Receivables Setup";
begin
SalesnRec.Get();
clear(json);
json := '';
HttpsContent.WriteFrom(json);
HttpsContent.GetHeaders(RequestHeader);
URL := StrSubstNo(SalesnRec."API URL" + Parameter1 + '/' + Parameter2);
HttpClient.DefaultRequestHeaders.Add('WebsiteGuid', SalesnRec."Website-GUID");
IF HttpClient.Post(URL, HttpsContent, HttpResponse) THEN BEGIN
HttpResponse.Content.ReadAs(ResponseText);
Message(ResponseText);
END;
end;
Expected behavior
This error should Not occur. As in previous version(12.XX) of Sandbox environment. Same extension was working properly.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions:
- AL Langauge: 13
- Business Central: 13.XX
Describe the bug
Have used "Http Client" in one of the extension. And when this extension is triggered, getting error "Microsoft.Dynamics.Nav.Runtime.NavHttpContent Variable not initialized"
To Reproduce
Have created an extension in which i have used "HttpClient" to consume a DotNet webservice. Below are the code:
procedure GetWeb(Parameter1: Code[20];Parameter2:Code[20]);
var
HttpClient: HttpClient;
HttpResponse: HttpResponseMessage;
ResponseText: Text;
URL: Text;
HttpRequest: HttpRequestMessage;
SubFolder: Text[100];
OrderNo: Code[20];
HttpsContent: HttpContent;
HttpsHeader: HttpHeaders;
ReturnValue: ARRAY[20] OF Text[1000];
jObj: JsonObject;
json: Text;
SalesnRec: Record "Sales & Receivables Setup";
begin
SalesnRec.Get();
clear(json);
json := '';
HttpsContent.WriteFrom(json);
HttpsContent.GetHeaders(RequestHeader);
URL := StrSubstNo(SalesnRec."API URL" + Parameter1 + '/' + Parameter2);
HttpClient.DefaultRequestHeaders.Add('WebsiteGuid', SalesnRec."Website-GUID");
IF HttpClient.Post(URL, HttpsContent, HttpResponse) THEN BEGIN
HttpResponse.Content.ReadAs(ResponseText);
Message(ResponseText);
END;
end;
Expected behavior
This error should Not occur. As in previous version(12.XX) of Sandbox environment. Same extension was working properly.
Screenshots
If applicable, add screenshots to help explain your problem.
Versions: