Hello Experts,
Error Message:
A call to System.Net.HttpWebRequest.GetResponse failed with this message: The request was aborted: Could not create SSL/TLS secure channel.
I am facing this error while working on E-Invoicing integration.I have doubt in Security Protocol Type but used others also like Tls,Tls11,Tls12,Tls13,Ssl3 but still same error.Plz help
My Code is:
//GetJson;
CLEAR(DataExch);
CreateJSONSalesInvoice(Rec);
IF FILE.EXISTS(GetClientFile + 'J.txt') THEN
ERASE(GetClientFile + 'J.txt');
FL.CREATE(GetClientFile + 'J.txt');
FL.CREATEOUTSTREAM(OutStrm);
OutStrm.WRITETEXT(FORMAT(Json));
FL.CLOSE;
IF CONFIRM('Do you want view the JSON ?') THEN
//MESSAGE('%1',FORMAT(Json));
IF NOT CONFIRM(FORMAT(Json)) THEN
EXIT;
//To Get Request No.
EInvIntegrationSetup.GET;
HttpWebRequestMgt.Initialize(FORMAT(EInvIntegrationSetup."Generate E-Invoice URL"));
HttpWebRequestMgt.DisableUI;
ServicePMgr.Expect100Continue:=TRUE;
ServicePMgr.SecurityProtocol(SecurityProtocal.Tls12);
HttpWebRequestMgt.SetMethod('POST');
HttpWebRequestMgt.SetReturnType('application/json');
HttpWebRequestMgt.SetContentType('application/json');
HttpWebRequestMgt.AddHeader('Authorization',FORMAT(EInvIntegrationSetup."Bearer Token"));
HttpWebRequestMgt.AddBody(GetClientFile + 'J.txt');
TempBlob.INIT;
TempBlob.Blob.CREATEINSTREAM(ResponseInStream_L);
IF HttpWebRequestMgt.GetResponse(ResponseInStream_L,HttpStatusCode_L,ResponseHeaders_L) THEN BEGIN
ResponseInStream_L.READ(ResponseText);
//MESSAGE('%1',ResponseText);
Json := ResponseText;
ReadJSon(Json,DataExch);
IF GetJsonNodeValue('status.message') = 'Error' THEN
ERROR(GetJsonNodeValue('datalist..error.message.message'));
ReqNo := '';
ReqNo := GetJsonNodeValue('request');
SLEEP(2000);
//To Get E-Invoice
//MESSAGE('%1',FORMAT(EInvIntegrationSetup."Get Url") + GetJsonNodeValue('request'));
HttpWebRequestMgt.Initialize(FORMAT(EInvIntegrationSetup."Get Url") + ReqNo);
HttpWebRequestMgt.DisableUI;
HttpWebRequestMgt.SetMethod('GET');
HttpWebRequestMgt.SetReturnType('application/json');
HttpWebRequestMgt.SetContentType('application/json');
HttpWebRequestMgt.AddHeader('Authorization',FORMAT(EInvIntegrationSetup."Bearer Token"));
ServicePMgr.Expect100Continue:=TRUE;
ServicePMgr.SecurityProtocol(SecurityProtocal.Tls12);
TempBlob2.INIT;
TempBlob2.Blob.CREATEINSTREAM(ResponseInStream_L);
IF HttpWebRequestMgt.GetResponse(ResponseInStream_L,HttpStatusCode_L,ResponseHeaders_L) THEN BEGIN
ResponseInStream_L.READ(ResponseText2);
//MESSAGE('%1',ResponseText2);
Json2 := ResponseText2;
ReadJSon(Json2,DataExch);
IF GetJsonNodeValue('status.message') = 'Error' THEN
ERROR(GetJsonNodeValue('datalist..error.message.message'));
InsertResponse_New(Rec."No.",1,'');
COMMIT;
IF GetJsonNodeValue('datalist..einv.Irn') <> '' THEN
MESSAGE(Text50000,Rec."No.")
ELSE
//ERROR('E-Invoice not generated.');
MESSAGE('E-Invoice Request No. Updated !!');
END;
END ELSE
ERROR('E-Invoice not generated.');
0