Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to call third party API when "post" action in the Sales Order in Dynamics 365 Business Central

(0) ShareShare
ReportReport
Posted on by 44

Hello, I'm new to Dynamics 365 and I have a requirement to integrate a third-party system into Dynamics 365 Business Central.

We need to call third-party API when the "Post" action performed in the Sales Order screen by the user in Dynamics 365 Business Central. 

Anybody has worked on calling API from D365 Business Central,  please give some inputs on how to achieve this.

Appreciate any help!

Thanks!

  • Verified answer
    JAngle Profile Picture
    33,135 on at
    RE: How to call third party API when "post" action in the Sales Order in Dynamics 365 Business Central

    Appsource explanation is much more long winded. Once you have it working I’d look at that as a completely separate learning exercise. Try this for now: community.dynamics.com/.../how-to-install-an-extension-created-from-the-sandbox

  • Suggested answer
    Vijay Jupudi Profile Picture
    44 on at
    RE: How to call third party API when "post" action in the Sales Order in Dynamics 365 Business Central

    Thank you Josh for a detailed explanation.

        How to publish the new codeunit to Client Business Central Instance either through AppSource or another way to do that?

    Please provide any reference docs or links to me & will walk through it.

  • Verified answer
    JAngle Profile Picture
    33,135 on at
    RE: How to call third party API when "post" action in the Sales Order in Dynamics 365 Business Central

    Adding to the answer from Suresh.

    You can use a codeunit to create an event subscriber to the Sales Post codeunit. This will enable you to make the HTTP call as Suresh has suggested at the right point in the posting sequence

  • Verified answer
    Suresh Kulla Profile Picture
    43,636 on at
    RE: How to call third party API when "post" action in the Sales Order in Dynamics 365 Business Central

    I have done several integrations to third party API, you can use HttpClient to send the request, below is a simple example 

    RequestHeaders := HttpClient.DefaultRequestHeaders();
    RequestHeaders.Add('Authorization', ''); // Add the authorization based on the API
    RequestMessage.SetRequestUri(ApiURl));
    RequestMessage.Content.WriteFrom(CreateJsonRequest());
    RequestMessage.Method('POST');
    IsSuccessful := HttpClient.Send(RequestMessage, ResponseMessage);
    
    CreateJsonRequest is a method which creates a Json and returns the JsonText.

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

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

Featured topics

Product updates

Dynamics 365 release plans