Setting the Content_type in the Header when passing parameter using POST

Not applicable

Hi,

I have a particular type - Content_Type (application/vnd.com.mycar.myapi.v2.0+xml) which I must have to set as Header value when calling Target URL and I need to pass some Request Body Parameters (4-5 Request body parameters). I am creating a Request Paylaod in Assign Message Policy with all Request Body parameters.

When I am using Content-Type = application/vnd.com.mycar.myapi.v2.0+xml

, - request paylaod not retrieve the request body parameter in the paylaod. It allow only when Content-Type = application/x-www-form-urlencoded. I need to set my Content_Type as -

application/vnd.com.mycar.myapi.v2.0+xml

Any idea - How it is possible to pass body parameter with Content_type=

application/vnd.com.mycar.myapi.v2.0+xml

0 2 1,509
2 REPLIES 2

sidd-harth
Participant V

Hi @RejeevChaturvedi, did you try to Set the Content_Type header in the same Assign Message policy in which you have request body parameters?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1">
    <DisplayName>Assign Message-1</DisplayName>
    <Set>
        <QueryParams/>
        <FormParams/>
        <Payload/>
        <Headers>
         <Header name="Content_Type">application/vnd.com.mycar.myapi.v2.0+xml</Header>       </Headers>
    </Set>
    
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

Let me know if it worked.

I think you need to read the request parameters before you set the Content-Type header.