API Gateway: Convert JSON body into JSON string to be used in Custom Extension?

Hello. I have a question as my continuation of my questions regards of converting JSON into XML.

So, as stated in the other topic, I need to use Custom Extension in order to invoke another service before the output is sent to the Routing part. Now, the service, we’ll consider it summoned by: service:jsonConverter. However, the service has an input which reads a jsonString. And I want to take the invoked JSON body to be converted into JSON String and then used as a parameter. Ideally, it would be “service:jsonConverter?input=(insert json string here)”. But… how do I facilitate that?

I really need a quick help here, so please let me know ASAP. Thank you!

Can you share your definition of “invoked JSON body”? JSON has one form – a string. There is no other representation.

I’m having trouble understanding specifically what you’re trying to do to implement the JSON to XML conversion. Perhaps you can share a screen shot or two?

Invoked JSON body: When you try to use something like Postman to hit an URL with the POST method, you write a JSON string over there. For example:

{
	"jsonString": {
		"id": 10,
		"name": "Dave"
	}
}

That is what I meant ‘JSON Body’. If it’s actually called JSON String, then… okay, we’ll just call it that way.

It’s night and I’ll try to share screenshot tomorrow. But, in short: I’m trying to use an API Gateway to call into an URL, but during the Request Processing section, I would invoke another IS Service to convert the JSON String into XML String, because the service being called in the Routing section only accepts XML String. Once the routing section is done, the Response Processing section will re-convert the XML String into JSON String to be returned to the user.

And so the question is, I want the JSON String that was posted to be used as a parameter when invoking the IS Service in Request Processing. Be it using Custom Extension (if the IS is not in a local server) or the traditional Invoke webService IS (if the IS is in a local server). That’s my goal. Help will be very much appreciated.

EDIT: I’ll try to picture the desired flow of the data within the Policy screen with the screenshot below. I hope you get the general idea with it.