Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Unanswered

I Need Example how create JSON Port and Send it to API web-servise

(1) ShareShare
ReportReport
Posted on by
Hi For All,,,
 
I would like to thank everyone who helps me solve the problems I have,,,,,,,
 
Please excuse me because my English is not strong
 
Required description :-
I am required to Integration with the General Tax Office (Government Side) so that companies can send sales & return invoices in JSON and receive them through the API service
Note : After preparing the invoice in XML format, the file is encoded in Base64 and included in a JSON file with the addition of
Client-ID use (
UBL 2.1 Invoice)
 
2-After the sending process, the server responds with a JSON file containing messages indicating the success of the process and its compliance with the requirements
Its failure
3-If the process is successful, the file contains: The QR Code must be shown on the seller’s invoice
 
I searched for a long time on the Internet and did not find an example......
 
Is there an example of how to get started in AL Code?
 
  • Rami Mazrawi Profile Picture
    Rami Mazrawi on at
    I Need Example how create JSON Port and Send it to API web-servise
    thank You gdrenteria ,,,
     
    I write the following code and gave it any data to verify the sending and receiving From URL,,,,, but a appear error appears in the image.
     
    the Code Photo :
    ===================================================================================================
    ===================================================================================================
    the code Text :
    procedure SendInvoiceWithAuthentication(EncryptedXMLBase64: Text[1000]; ClientID: Text[200]; SecretKey: Text[500])
        var
            HttpClient: HttpClient;
            HttpRequestMessage: HttpRequestMessage;
            HttpResponseMessage: HttpResponseMessage;
            RequestHeaders: HttpHeaders;
            JsonToken: JsonToken;
            JsonObject: JsonObject;
            BodyText: Text;
            BaseUrl: Text;
            ResponseContent: Text;
        begin
            BaseUrl := 'https://backend.jofotara.gov.jo/core/invoices/';
            HttpRequestMessage.SetRequestUri(BaseUrl);
            HttpRequestMessage.Method('POST');
            // إضافة رؤوس الطلب ********************************************
            HttpRequestMessage.GetHeaders(RequestHeaders);
            RequestHeaders.Add('Client-Id', ClientID);
            RequestHeaders.Add('Secret-Key', SecretKey);
            RequestHeaders.Add('Content-Type', 'application/json');
            // إعداد جسم الطلب *********************************************
            JsonObject.Add('invoice', EncryptedXMLBase64);
            JsonObject.WriteTo(BodyText);
            HttpRequestMessage.Content.WriteFrom(BodyText);
            // إرسال الطلب والتعامل مع الرد ********************************
            if HttpClient.Send(HttpRequestMessage, HttpResponseMessage) then begin
                HttpResponseMessage.Content.ReadAs(ResponseContent);
                if HttpResponseMessage.IsSuccessStatusCode then begin
                    // الرد ناجح
                    // هنا يمكن تحليل الرد ومعالجة QR Code أو غيره
                    Message('Success: %1', ResponseContent);
                end else begin
                    // الرد يدل على وجود خطأ
                    Message('Error: %1', ResponseContent);
                end;
            end else begin
                Message('Failed to send request.');
            end;
        end;
     
     
    Please help me solve the problem and understand what is happening
     
     
     
  • gdrenteria Profile Picture
    gdrenteria 12,920 Most Valuable Professional on at
    I Need Example how create JSON Port and Send it to API web-servise

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans