question

VinodRamasubbu-4550 avatar image
0 Votes"
VinodRamasubbu-4550 asked amanpreetsingh-msft commented

Getting an Azure AD token to send events to an event hub is not working

I followed the below document and tried getting an access token from Azure AD.

I am getting an error that request body must contain grant_type ,even though its being pass as part of the request body.
I tried the same with postman and got the same error.

https://docs.microsoft.com/en-us/rest/api/eventhub/get-azure-active-directory-token#see-also

curl --location --request GET 'https://login.microsoftonline.com/MY-TENANT-ID/oauth2/token' --header 'Content-Type: application/x-www-form-urlencoded' --form 'grant_type="client_credentials"' --form 'client_id="MY-CLIENT_ID"' --form 'client_secret="MY-CLIENT-IDS-SECRET"' --form 'resource="https://eventhubs.azure.net"'

{"error":"invalid_request","error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r\nTrace ID: 80a20306-05bf-4054-b240-b1eb1ec0d300\r\nCorrelation ID: 0292cf87-b34d-4586-b89b-e057741bc3fa\r\nTimestamp: 2021-07-15 14:38:29Z","error_codes":[900144],"timestamp":"2021-07-15 14:38:29Z","trace_id":"80a20306-05bf-4054-b240-b1eb1ec0d300","correlation_id":"0292cf87-b34d-4586-b89b-e057741bc3fa","error_uri":"https://login.microsoftonline.com/error?code=900144"}

azure-ad-authenticationazure-ad-app-registrationazure-event-hubs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

amanpreetsingh-msft avatar image
0 Votes"
amanpreetsingh-msft answered amanpreetsingh-msft commented

Hi @VinodRamasubbu-4550 · Thank you for reaching out.

You need to replace Content-Type: with Content-Type= to set its value to application/x-www-form-urlencoded. You can also set Content-Type to application/form-data. Both works.


Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @VinodRamasubbu-4550 · Just checking if you had a chance to test it out.

0 Votes 0 ·