What is Issue?
MS CRM provides the way to get data from entities with calling Web API. But mostly we use this API calls within CRM application. When calling Web API within CRM , user is already logged in to the CRM which do not need any extra authorization. When we try to calls these Web API out side CRM it requires authorization to access data from CRM.
To Call Web APIs outside MS CRM environment you need to get Bearer token for the user using OAuth2.0 authorization.
Lets take example – WebAPI to get all Accounts- https://xxxxx.crm8.dynamics.com/api/data/v8.2/accounts
Lets generate bearer token to access above WebAPI from Postman-
I am considering You have registered the Azure app and you have Client Id and Client secrete with you for this app.
In Postman- New request add your request –
- Go to the Authorization tab
- Select Type – OAuth2.0
- Click on Get New Access Token
- In popup window please enter all required information as below-
- Grant Type – Authorization Code
- Enter Callback URL provided in Azure App – Redirect URI
- Enter Auth URL –
- Access Token URL –
- Enter Client Id and Client Secret you have.(Azure App client details).
- Click on Request Token.
- Microsoft login window will popup. Enter your credentials to login.On successful authentication, It will bring an access token for you.
- Select Access Token you have generated just a while before from Available tokens in postman.
- Don’t forget to select Add authorization data to – Request Header
- Now you can send the request and test your MS CRM Web APIs.
- You can use the Code option in postman to generate code according to your programming needs.
You can use the same parameters when generating bearer token for the user using code.
How to get bearer token using Postman-
- Use Post Method and URL-
- Add below details to Body of the request as form-data-
– grant_type – client_credentials
– user’s credentials : username and password
– other details – client_id and client_secret as described above. -resource : your MS CRM url.
Using the bearer token generated you can access MS CRM Web APIs in any application.
Hope this will help…
Enjoy Ms CRM!!!
Follow on Facebook- FB: MSCRM16Tech