how do i remove the attributes of an header? example I don't want charset=utf-8 to go to the backend.

Not applicable

my request content is json and has this attribute but i am transforming it to all to query param and dont require this to be present

0 3 3,564
3 REPLIES 3

sarthak
Participant V

@dj1 You can use assignMessage Policy. Use the remove attribute.

Learn more here : http://apigee.com/docs/api-services/reference/assign-message-policy

This is how the AssignMessage policy should look like for you :

<AssignMessage>
<Remove>

 <Headers> 

  <Headername="a_header_name"></Header> </Headers> 

 </Remove>

</AssignMessage>

Sarthak is right that you can just use the Remove element in the AssignMessage policy to strip the header off.

If you need to leave the Content-Type header there, but remove the charset, I would use a JavaScript or Python policy since you're effectively doing some string manipulation.

This example JavaScript policy strips the charset from the content-type header. I haven't tested for all edge cases, YMMV.

var cType = context.getVariable("request.header.content-type")
print('unmodified: ' + cType)
cType = cType.split(';')[0]
print('modified: ' + cType)
context.setVariable("request.header.content-type", cType)

Print statements are only in there for easy validation in Trace.

You could do something similar with an extension policy to get the value of the Content-Type header without the charset for use later on -- e.g. in your AssignMessage policy to set the query parameter you want to use.

Thanks @Carlos Eberhardt and @sarthak , got it working