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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Code to call APIs from X++

(1) ShareShare
ReportReport
Posted on by 184

Hi All,

I have a requirement for calling an API to send customer payment details to a thrid party tool.

I have two APIs  

1. API for Token

2. API for Payment

Please suggest me how can I achieve via x++, any sample code would be much appreciated?

APIs based of standard header authentication .

And I client has the following to me

1. Token URL

2. API URL

3. CLient ID

4. Secret

Please suggest some answers

I have the same question (0)
  • Anthony Blake Profile Picture
    2,700 Super User 2025 Season 2 on at
    Code to call APIs from X++
    Hi, take a look at the exchange rate providers in standard, they call external APIs, albeit to get and not post, but the logic could be a starter for you.
  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    HI Siabi,

    Thanks for responding,

    Yes I am generating token in X++.

    If you have any sample code where to generate token and consuming the token and passing values to Payload , please share with me as I will pick up from using the same

  • Suggested answer
    Komi Siabi Profile Picture
    13,047 Most Valuable Professional on at
    RE: Code to call APIs from X++
    [quote user="D365_Wibes"]

    I was able to generate token sucessfully.

    [/quote]

    Are you generating the Token with an X++ class already ?

    [quote user="D365_Wibes"]

    Can you please let me know how to consume the token in my another API?

    [/quote]

    You can call your class to generate the Token in the class used to send payment.

    [quote user="D365_Wibes"]

    Also could you please let me know how to pass values to the Payload ?

    [/quote]

    You pass the value in your method inside the class used for sending the payment.

    I actually do not know the parameters of the payload given to you.

  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    Hi Siabi,

    I was able to generate token sucessfully.

    Can you please let me know how to consume the token in my another API?

    Also could you please let me know how to pass values to the Payload ?

    Please give me some suggestions.

  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    Hi Siabi ,

    I will keep you updated on this as I am trying the sae

  • Komi Siabi Profile Picture
    13,047 Most Valuable Professional on at
    RE: Code to call APIs from X++

    Hi D365_Wibes ,

    I think, my major question will be, are you able to connect to the service in your X++ project as we write?

  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    Hi Siabi,

    Can you please suggest something?

  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    Thanks for sharing that Siabi

    But the link you have shared via which I can get the JSON,

    but I should also have to write some thing in it and send it back to 3rd party tool...

    Let me tell you my full requirement.

    1. In D365 FO on daily basis I need to push customer payments posted against an Invoice for the day to a

      3rd party tool,

    2.  I will write a batch service which will run on every night. Now I want to incorporate the api in the batch

       service.

    3. I have the valid JSON format with me available ready.  I just have to write some values into the JSON and send it to the 3rd party via POST api call.

    Hope I have explained little better about my requirement. Kindly suggest me accordingly to achieve the requirement

  • Suggested answer
    Komi Siabi Profile Picture
    13,047 Most Valuable Professional on at
    RE: Code to call APIs from X++

    Hi D365_Wibes,

    Please, are you saying, you did not get anything from the link I shared?

  • D365_Wibes Profile Picture
    184 on at
    RE: Code to call APIs from X++

    Hi Martin,

    Can you please suggest some code? I am not sure how to achieve this

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,258

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 949 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 631 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans