Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : cKWdT2+A9vIgd2Dpr1C8zH
Finance | Project Operations, Human Resources, ...
Answered

Rest API GET call JSON format using basic authentication in Dynamics 365

Like (0) ShareShare
ReportReport
Posted on 6 Feb 2020 15:32:40 by 505

Hi all,

I have Third-party application hosting REST API which returns JSON. I am consuming this service in D365.

For consuming I followed the blog https://rahulmsdax.blogspot.com/2018/12/rest-api-get-call-json-format-using.html

when I am trying to consume in Runnable class, I am getting exception when I am trying to get response from request

pastedimage1581002934345v1.png

pastedimage1581002951023v2.png

Exception is

Error executing code: Wrong argument type for function.

were as GetResponse() method, Do not expect any parameter.

I tried

1) clearing Usage Data

  • Verified answer
    Martin Dráb Profile Picture
    231,768 Most Valuable Professional on 18 Feb 2020 at 06:20:27
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    First of all, find out which types of authentication the third-party application supports. Consult its documentation, ask the author or so.

    Then evaluate which one is the most suitable for you.

  • Ishu.caddengg@hotmail.com Profile Picture
    505 on 16 Feb 2020 at 06:45:12
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Hi Martin,

    Please let me know what all details are required

  • Martin Dráb Profile Picture
    231,768 Most Valuable Professional on 13 Feb 2020 at 16:31:47
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Most likely it's because you're not authenticating correctly. I can't give you any more specific answer if you don't provide any more details.

    Whether the service is RESTful or not, whether you use JSON, XML or another data format, these things are not important. Focus on authentication instead.

  • Ishu.caddengg@hotmail.com Profile Picture
    505 on 12 Feb 2020 at 10:15:35
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Thanks for the reply

    Out of curiousity again I am raising few question

    1) When I tried CONSUME web service of Third party app

         A) if we consume SOAP based --> D365FO was able to connect and read/respond the data

         b) if we consume REST API JSON --> D365FO is getting Authentication error(whose screenshot is attached in above trail).

    What could be the reason behind this?

  • Martin Dráb Profile Picture
    231,768 Most Valuable Professional on 12 Feb 2020 at 08:13:59
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Yes, I understand your scenario - that's why I said what I said.

    You said that "Now it is clear to do it in AZURE we have to register in AAD", but that's far from clear. It would be true only if the third-party application required AAD authentication, but you never said anything like that. On the contrary, you're explicitly trying to use a different authentication mechanism than AAD.

    It seems to me that you're still confused by the information from Will, which doesn't apply in your case. It would be used if you called F&O API from outside - then you'd need AAD, because F&O API depends on AAD. But you're talking about calling the third-party API, not F&O API.

    Regarding your questions:

    1) Is it mandatory to provide USER ID while consuming it? No, it depends on the authentication mechanism used by the third-party application.

    2) f everything run on Web Server, it should take authentication from IIS App pool? No. as I said you have no control over these things and you can't depend on it. Even the assumption and the web server will be IIS may be wrong.

    3) What is the option available other than "Basic Authnetication"? There are many options in general, but it's not really the right question. You want to call an API of a specific third-party application and the question should be what this app supports. If what the app natively supports doesn't meet your needs, you could use some kind of middleware.

  • Ishu.caddengg@hotmail.com Profile Picture
    505 on 12 Feb 2020 at 05:52:21
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Hi Martin,

    I guess, I did not clear things from starting, please go through the below

    Sorry I am bit confuse with your reply

    There is JSON REST API is exposed by Third-party application. In D365 F&O, we have to consume it.

    First we have to do the same in IN House VM then we will move it to Azure.

    While doing the same in ON Premise, we are getting error for Authentication

    Now it is clear to do it in AZURE we have to register in AAD.(keeping this part aside for a while)

    Before that for ON Premise, I want to understand how the authentication take place.

    1) Is it mandatory to provide USER ID while consuming it ?

    2)If everything run on Web Server, it should take authentication from IIS App pool?

    3) What is the option available other than "Basic Authnetication"?

  • Ishu.caddengg@hotmail.com Profile Picture
    505 on 12 Feb 2020 at 05:46:59
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Hi Will,

    There is JSON REST API is exposed by Third party application. In D365 F&O, we have to consume it.

    First we have to do the same in IN House VM then we will move it to Azure.

    While doing the same in ON Premise, we are getting error for Authentication

    Now it is clear to do it in AZURE we have to register in AAD.

    Before that for ON Premise, I want to understand how the authentication take place.

    1) Is it mandatory to provide USER ID while consuming it ?

    2)If everything run on Web Server, it should take authentication from IIS App pool?

  • Martin Dráb Profile Picture
    231,768 Most Valuable Professional on 10 Feb 2020 at 07:26:10
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Note that the last reply applies in the opposite case - if the external application called in F&O instead of F&O calling the app.

  • WillWU Profile Picture
    22,352 on 10 Feb 2020 at 03:39:56
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    Hi partner,

    Do you mean that you want to integrate with third-party application?

    Before any apps can communicate with Dynamics 365 for Operations services, they must be registered in AAD.

    More information about registering applications in AAD here:

    https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app

    If you want to integrate data from external apps.

    You can also try BYOD and Azure Service Bus.

    Hope this helps.

  • Martin Dráb Profile Picture
    231,768 Most Valuable Professional on 09 Feb 2020 at 17:45:33
    RE: Rest API GET call JSON format using basic authentication in Dynamics 365

    The RunOn property and client/server keywords in X++ have no meaning in F&O. Unlike in older versions, there is no client application running X++. All X++ code now executes on the web server.

    To be callable from cloud, the third-party must either be open to the internet or (which is safer) you'll need some kind of proxy (an example).

    I think you'll have to use explicit credentials when calling the service, because you have no controls over accounts of environments hosted by Microsoft. By the way, don't forget that Basic Authentication doesn't use encryption, therefore either build a secured channel or avoid Basic Authentication completely.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,886 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,768 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading complete