How to add custom headers at parent level
Hello,
I am trying to add custom headers at the parent level so that every request does not have to be individually tailored. I see there may be some scripting options or property expansions but I can't find a good way to implement it and where to implement it.
Say I want to add custom header: "x-id: value" to all requests.
How would I go about doing that?
Thank you
You can do this at the parent level (by that I am guessing so that all requests use the same headers is what you want) - by doing so in an event handler.
So that in the RequestFilter.filterRequest event handler if you want to add "Content-Type: application/x-www-form-urlencoded" as a header you can do it the following way:
def headers = request.requestHeaders // I clear out all request content, but you might not want to do this: context.setProperty("requestContent", '') request.requestContent = '' // add the header headers.put( "Content-Type", "application/x-www-form-urlencoded") request.requestHeaders = headers
Now every request will have the "application/x-www-form-urlencoded" Content-Type.
Bill