vinit sawant Thanks for posting your question in Microsoft Q&A. As discussed in other Q&A thread, you need to make a POST
request to the endpoint in order to get JSON response back. If you make a GET
request, the endpoint might not return a JSON response and hence processing the response body as JSON will threw an error as you mentioned.
I understand POST
request threw a bad request error, and suggest you validate client id, scope, secret credentials etc. as I don't see any issue with the code snippet (sample reference). You can also make this POST
request from other tools such as Postman to validate the request and response.
To troubleshoot this in APIM, use Trace a call option to capture a trace and investigate the request sent from APIM to the endpoint and review the full error message including stack trace if any. If so, share the full error details including request ID/correlation ID, timestamp. That will help in investigating further.
I hope this helps and if you face any issues or questions, feel free to reach out.
If you found the answer to your question helpful, please take a moment to mark it as Yes
for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.