I have to use raw json in my post query to Azure Key Vault. Which I've done like so:
{ "grant_type":"client_credentials" }
I get a 400 error complaining that the body does not have 'grant_type'
How can I get Azure Key Vault API to accept the raw json body?
The headers are in the attached image
body in Postman: body
using urlencoded in raw-JSON body
The endpoint is: https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token which returns a temporary access token.
Microsoft has confirmed with me that this endpoint cannot accept raw-JSON so I'll have to find some other way for my implementation.
CodePudding user response:
Your post data needs to be URLEncoded. This can be done in Postman using a pre-request script. You can read the full walk-through on Jon Gallant's blog here: Azure REST APIs with Postman or watch the video here: https://learn.microsoft.com/en-us/rest/api/azure/
CodePudding user response:
This endpoint cannot read raw JSON.
The only solution is to modify the request body to use urlencoded format.
In Postman this can be done by changing the content type to: application/x-www-form-urlencoded
and the body to Raw with the content inside the body as &{key}={value} for every key, value that the endpoint requires.
Without access to the API sending the request I'm unfortunately unable to solve this issue since I'm forced to use JSON objects as the request body.