web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Irn generation issue in bussines central

(0) ShareShare
ReportReport
Posted on by 73

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
       
        IRNPostUrl := 'xyz.com/.../invoice';


        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;
I have the same question (0)
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,290 Moderator on at
    RE: Irn generation issue in bussines central

    Yes, DotNet won't work in BC SaaS. You'll have to use the inbuilt JSON variables

    Check this link to get started

    www.youtube.com/watch

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,901

#2
YUN ZHU Profile Picture

YUN ZHU 2,079 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 2,041

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans