0
votes

I am using WSO2 Api Manager as a proxy between a client and the server. The server sends XML responses that I successfully converted to a JSON response with a custom PayloadFactory message mediation. Problem that I now am facing is the following: How do I mediate based on the accept headers of a request?

When I have in the header of a request: Accept application/json I want to use my mediator to convert the response from the server to JSON, but when I have Accept text/xml or application/xml I don't want to use my mediator and just forward the response as is.

Edit: Basicly the only thing a really need is to save my "Accept ... " header. I can forward it to the server, but the server doesn't do anything with it. Are there global variables or something that I can use per proxy request?

Any advice will be appreciated.

1

1 Answers

0
votes

You can use Filter mediator or Switch mediator to do a if-then-else kind of operations inside the insequence and implement your first requirement. You can get the header using synapse xpath variables. You can define a custom sequence and add it to the api

for the second question, you can use property mediator to define values and use them later. set the 'Scope' parameter according to your need