Vijay Sharma Thanks for posting your question in Microsoft Q&A. Based on your description, you got JSON response from API call and like to retrieve access_token from the response body.
I used the sample response above and using set-body liquid template, you can set the body with access token as below:
<outbound>
<set-body template="liquid">
{
"access_token": "{{body.access_token}}"
}
</set-body>
<base />
</outbound>
Output:
If you are looking to set it in a variable for storing it in cache, you can try the below snippet:
<outbound>
<set-variable name="access-token-value" value="@{
var response = context.Response.Body.As<JObject>();
return response["access_token"];
}" />
<base />
</outbound>
Note, these are just code snippets, and you can customize it based on the need. I hope this helps with your question and let me know if you face any issues or have any additional questions.