Reconstruct the target API response JSON schema

I did make API proxy using the public API, which return the JSON payload. I want to change this JSON payload data schema so that we will pass the reconstructed JSON as a response of the API proxy.

It looks like either Variable Policy or JS policy could be the ones I should refer, but I appreciate if someone guide me to the right direction.

0 4 249
4 REPLIES 4

Not applicable

I would suggest to use assign message policy and/or javascript policy.

You may use extract variable and assign message also.

You can use java callout or python also.

For performance I would suggest first java, but debugging and code change is difficult.

Thank you for your response. I only know JavaScript for coding , python or java is not optio with me.

Sounds like assign message or JavaScript policy should be option with me but I never use those. Where do I can fine detailed docs or tutorials?

My case is I got JSOn as response from target api. I can not pass it as it is to my service. I need to re construct JSON schema to match particular format .

Javascript is fine. You can collect the response in javascript using

var oldbody = context.getVariable("response.content");

Then after modification do,

context.setVariable("response.content", newpayloadvar);