Hello All,I have done customization to generate IRN for India localization in business central cloud ,but i'm getting below error while generating IRN. Below is my code .can anyone suggest me.
procedure AcquireToken(
): Text;
var
Client: HttpClient;
Request: HttpRequestMessage;
Response: HttpResponseMessage;
Content: HttpContent;
JAccessToken: JsonObject;
ContentHeaders: HttpHeaders;
//UriBuilder:DotNet UriBuilder;
ContentText: Text;
ResponseText: Text;
IsSuccess: Boolean;
Jtoken: JsonToken;
Json_Object: JsonObject;
ValueJtoken: JsonToken;
Rsp: Text;
begin
// ContentText :=
// 'gspappid' + '79536E39F216449883720CCD53643D8F' +
// 'gspappsecret' + 'EE5EFAACG8434G43E8GA90EG9660E98C3D71'
// ;
//Content.WriteFrom(ContentText);
Content.GetHeaders(ContentHeaders);
ContentHeaders.Remove('Content-Type');
ContentHeaders.Add('Content-Type', 'application/json');
ContentHeaders.Add('gspappid', 'xyx');
ContentHeaders.Add('gspappsecret', 'abc');
Request.Method := 'POST';
Content.GetHeaders(ContentHeaders);
//gsp.adaequare.com/.../invoice
Request.SetRequestUri('gsp.adaequare.com/.../authenticate
//Request.SetRequestUri('gsp.adaequare.com/.../authenticate
Request.Content(Content);
if Client.Send(Request, Response) then
if Response.IsSuccessStatusCode() then begin
if Response.Content.ReadAs(ResponseText) then
IsSuccess := JAccessToken.ReadFrom(ResponseText);
end else
if Response.Content.ReadAs(ResponseText) then
JAccessToken.ReadFrom(ResponseText);
Jtoken.ReadFrom(ResponseText);
if Jtoken.IsObject then begin
Json_Object := Jtoken.AsObject();
if Json_Object.Get('access_token', ValueJtoken) then begin
if ValueJtoken.IsValue then begin
Rsp := ValueJtoken.AsValue().AsText();
end;
end;
end;
exit(Rsp);
end;
procedure GenerateIRN(user_name: Text; password: Text; gstin: Code[15]; Authorization: Text; SalInvHdr: Record "Sales Invoice Header"): text
var
//IRNHttpWebRequestMgt: Codeunit 1297;
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;
fttt: Codeunit 1297;
hTTPhEADER: HttpHeaders;
Client: HttpClient;
Request: HttpRequestMessage;
Response: HttpResponseMessage;
//Content: HttpContent;
JAccessToken: JsonObject;
//ContentHeaders: HttpHeaders;
//UriBuilder:DotNet UriBuilder;
ContentText: Text;
ResponseText: Text;
IsSuccess: Boolean;
begin
//For BE
//IRNPostUrl:='gsp.adaequare.com/.../invoice';
//IRNPostUrl := 'gsp.adaequare.com/.../invoice';
content.WriteFrom(EinvJson);
Content.GetHeaders(ContentHeaders);
ContentHeaders.Remove('Content-Type');
ContentHeaders.Add('Content-Type', 'application/json;charset=UTF-8');
ContentHeaders.Add('user_name', user_name);
ContentHeaders.Add('password', password);
ContentHeaders.Add('gstin', gstin);
ContentHeaders.Add('requestid', GenerateReqId);
Content.GetHeaders(ContentHeaders);
//ContentHeaders.Add('Authorization', Authorization);
//client.DefaultRequestHeaders.Add('Content-Type', 'application/json; charset=utf-8');
client.DefaultRequestHeaders.Add('Authorization', Authorization);
Request.Method := 'POST';
Request.SetRequestUri('gsp.adaequare.com/.../invoice');
Request.Content(Content);
if Client.Send(Request, Response) then
if Response.IsSuccessStatusCode() then begin
if Response.Content.ReadAs(ResponseText) then
IsSuccess := JAccessToken.ReadFrom(ResponseText);
end else
if Response.Content.ReadAs(ResponseText) then
JAccessToken.ReadFrom(ResponseText);
Message(ResponseText);
exit(ResponseText);
end;
Hello,
Feel free to raise this issue to Microsoft via your partner or CSP if you do not get further traction from the community. We may ask you for some sort of repro steps in standard.
Thank you.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,188 Super User 2024 Season 2
Martin Dráb 230,030 Most Valuable Professional
nmaenpaa 101,156