Unable to pass the set-body in Send-response POST method

Pothiraj, Saranya-ADM 0 Reputation points

Hi Team,

I'm trying to get the bearer token and set variables as needed .

Then want to send request to the backend with the variables set above in send-request body.

User's image

I cannot see the body attached this post send-requestUser's image

But when i use same set-body in <return-response>, I can get the all the values correctly.

The same set-body doesn't show values in <send-request>.

Can you please help on this

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,726 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Charlie Wei 1,890 Reputation points

    Hello Pothiraj, Saranya-ADM,

    According to this document, you need to additionally use the set-header policy to set the Content-Type to application/json.

        <set-header name="Content-Type" exists-action="override">
        <set-body template="liquid">...</set-body>

    Best regards,

    If you find my response helpful, please consider accepting this answer and voting yes to support the community. Thank you!

  2. JananiRamesh-MSFT 20,826 Reputation points

    @Pothiraj, Saranya-ADM Thanks for getting back, instead of using the variable could you please add context.Response.Body directly as shown below.

    <send-request mode="new" response-variable-name="db_secret" timeout="20" ignore-error="true">
                <set-header name="X-Vault-Token" exists-action="override">
    			 <value>@(context.Response.Body.As<JObject>(preserveContent: true)["auth"]["client_token"].ToString())</value>
    0 comments No comments