0
My APIM is receiving request payload in POST request -
and I have to format and send to backend --
Formatted payload for BE

I have to add the 2 parameters after every newreq line and append 2 new lines after GET request line. how to achive this in apim.

    newreq
    Content-Type: application/http--I have to append these parameter in payload
    Accept: application/json
    GET Abc?$format=json HTTP/1.1
    newreq
    Content-Type: application/http
    Accept: application/json
    GET Abc?$format=json HTTP/1.1
    endnewreq
  • You can refer to [Set body](https://learn.microsoft.com/en-us/azure/api-management/api-management-transformation-policies#SetBody), [Need to modify response using Azure APIM set-body policy](https://stackoverflow.com/questions/64856029/need-to-modify-response-using-azure-apim-set-body-policy) [Azure API Management - How to send body along with my request](https://stackoverflow.com/questions/62003235/azure-api-management-how-to-send-body-along-with-my-request) and [Deep Dive on set-body Policy](https://azure.microsoft.com/en-us/blog/deep-dive-on-set-body-policy/) – Ecstasy Nov 26 '21 at 09:31

1 Answers1

0

You can read request body first and then append the parameters to object.

        <set-body>@{ 
        var requestBody = context.Request.Body.As<JObject>(preserveContent: 
        true);

        requestBody ["Content-Type"] = "Your Value";
        requestBody ["Accept"] = "Your Value";

        return requestBody.ToString();
        }</set-body>