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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

DHL Rest API

(3) ShareShare
ReportReport
Posted on by 46
Hi 
 
Does any one now an implementation for the DHL Rest APi inside AX2012? Or maybe can help me in general?
 
We are currently using the old dll to communicate with DHL for Labels. But it has to be changed to call Rest API with OAuth and I have no clue about this. 

 
Categories:
I have the same question (0)
  • Jonas "Jones" Melgaard Profile Picture
    4,985 Most Valuable Professional on at
    Hi,
     
    I haven't used the DHL interface, but interacting with Rest API's in AX2012 should not be a big issue.
     
    You mention that you are using a .DLL today. Is it part of an ISV solution, or have you written the integration yourselves?
  • CH-11030637-0 Profile Picture
    46 on at
    The dll is written in my own
  • Jonas "Jones" Melgaard Profile Picture
    4,985 Most Valuable Professional on at
    In that case I'd say it's fairly easy to implement in your DLL.
     
    I don't know your location, but this is an example of the American API: https://developer.dhl.com/api-reference/label-dhl-ecommerce-americas#get-started-section/ 
    You can just download the YAML specification and generate C# code from it, or test it using https://editor.swagger.io
     
    I haven't implemented an integration to DHL (here other's might chip in), but if you request a developer login it looks to be fairly straightforward.
  • CH-11030637-0 Profile Picture
    46 on at
    Hi 
    I think I am on the right but do have a question.
     
    How can I pass some data to the WebRequest.

    It is for authentication to get a Bearer token. Therefore I have to pass data with mit POST Request  like this: (http notation)
     
    grant_type=password&client_id=my_clientid&username=user-valid&password=SandboxPasswort2023!&client_secret=my_clientsecret
     
     
    The content type has to be 'application/x-www-form-urlencoded'
  • Martin Dráb Profile Picture
    237,963 Most Valuable Professional on at
    You can use a search engine to find examples of how to use WebRequest class. Here is one: https://stackoverflow.com/questions/46502978/post-xml-file-in-ax2012-using-httpwebrequest.
  • CH-11030637-0 Profile Picture
    46 on at
    @Martin Drab
     
    Thx Martin for sure you are right and my post was not clear enough or wrong. 
    I did that and actually something is passed to the web service but something to be wrong.
     
    I testet it with postman and I was able to send it correct and get the token of the DHL Authentication back. But If I pass the string (grant_type=password&client_id=my_clientid&username=user-valid&password=SandboxPasswort2023!&client_secret=my_clientsecret) with the webrequest I get an authentication error....
     
    Thats why I added the info the string is the notation from the http request code (from Postman) an my contenttype is  'application/x-www-form-urlencoded'

    So I thing the string I copied from the http source has to be different in the WebRequest but I don't know how it should look like.
  • Martin Dráb Profile Picture
    237,963 Most Valuable Professional on at
    Please be more specific: tell us what request you're sending (operation, URL, body, headers), then code where you're trying to send the same request and tell us more about the error (e.g. the type, the exact error message). A good idea would be also checking what actual request your code generated and comparing it what you wanted.
     
    It's not clear where you're using your string, but it sounds wrong to me in all cases. With OAuth, you should use the Authorization header, shouldn't you? In past, URL parameters for GET requests or the body for POST requests used to be used sometimes, but it's not recommended. The header is the normal approach.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans