0
votes

I am working on a mobile application (both iOS and Android in native code). In this there is functionality of login with Dynamics 365 and get contacts from it. In this I have used OAUTH2.0 library to implement login functionality. Login is working fine. Next, I want to fetch contacts from Dynamics 365 using API. So I am following below documentation link: https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/contact?view=dynamics-ce-odata-9

In mobile app, I am not getting any response when I call this API. Also there is no error.

When I try to call [organization URI]/api/data/v9.0/contacts from my computer browser then it gives me contacts after login. Do I need to pass any token/authorizationCode/header parameters etc while calling this API from mobile app? In documentation they didn't mention anything regarding which things I need to pass while calling contact API.

Also I am not sure if I must have to use its mobile SDK to implement this feature rather then normal API call?

2

2 Answers

0
votes

You will need to Register an app (CRM) with Azure Active Directory. Here is first link which will help you out.

Using postman you call call webapi follow all the steps in below link

0
votes

When you are opening the CRM in a browser window, it writes the Bearer Token and Refresh Token in cookies, which is used by mobile app as well. This cookies ensures the smooth single sign-on.

To achieve this in mobile app, during first time login you have to do the same logic using ADAL.js and generate the token to store in cookies using clientid of that registered app (this has CRM access scope defined) like @AnkUser mentioned.

While calling web api, you have to pass the Bearer Token in header to pass through. Whenever this token expires, you have refresh the token every time.

Read more