Hello All, I have created below function to generate IRN for BC cloud India localization. there is standard codeunit 1297(Http Web Request Mgt.) in business BUT its has scope of 'Onprem'.I have used 'HttpRequestMessage' dotnet variable but its giving me different result. Is there any way to handle http web request in business central cloud ?
procedure GenerateIRN(user_name: Text; password: Text; gstin: Code[15]; Authorization: Text; SalInvHdr: Record "Sales Invoice Header")
var
IRNHttpWebRequestMgt: HttpRequestMessage;
IRNPostUrl: Text;
contentHeaders: HttpHeaders;
content: HttpContent;
SInvNo: Text;
FilePath: Text;
FileName: Text;
IRNApiResult: Text;
IRNTempBlob: Codeunit "Temp Blob";
IRNInstr: InStream;
IRNResponseHeaders: HttpResponseMessage;
HttpResponse: HttpResponseMessage;
httpClient1: HttpClient;
begin
content.GetHeaders(contentHeaders);
contentHeaders.Clear();
contentHeaders.Add('Content-Type', 'application/json');
contentHeaders.Add('user_name', user_name);
contentHeaders.Add('password', password);
contentHeaders.Add('gstin', gstin);
contentHeaders.Add('requestid', GenerateReqId);
contentHeaders.Add('Authorization', Authorization);
//contentHeaders.Add()
//IRNHttpWebRequestMgt.Method.
// IRNHttpWebRequestMgt.Initialize(IRNPostUrl);
// IRNHttpWebRequestMgt.DisableUI;
IRNHttpWebRequestMgt.Content := content;
IRNHttpWebRequestMgt.SetRequestUri(IRNPostUrl);
IRNHttpWebRequestMgt.Method := 'POST';
GenerateJsonPayload(SalInvHdr);
SInvNo := CONVERTSTR(SalInvHdr."No.", '/', '_');
//FilePath := 'C:\Users\jitendra\Desktop\E- Invoice\Json\';
FilePath := 'C:\EinvJson\';
FileName := SInvNo + '.txt';
IRNTempBlob.CREATEINSTREAM(IRNInstr);
httpClient1.Post(IRNPostUrl, content, HttpResponse);
// IF IRNHttpWebRequestMgt.GetResponse(IRNInstr, IRNHttpStatusCode, IRNResponseHeaders) THEN BEGIN
// // MESSAGE('httpstatuscode : '+AuthHttpStatusCode.ToString);
// // MESSAGE(AuthResponseHeaders.ToString);
// IRNApiResult := IRNTempBlob.ReadAsText('', TEXTENCODING::UTF8);
// IF IRNApiResult <> '' THEN BEGIN
// end;
// end;
end;