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

Announcements

No record found.

News and Announcements icon
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;
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,410 Moderator on at

    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 664 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 446 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 282 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans