I have a setup where:
-
I have both a proxy API and a backend API.
-
The backend API is configured to return Content-Type: application/json.
-
The proxy calls the backend API using an invoke policy. ['tokenResponse' is my response object variable]
When I inspect the invoke response object in the proxy (e.g. context.message.body.write(JSON.stringify(context.get('tokenResponse'))) ), the body property shows as: "body":{"type":"Buffer","data":[123,34,97,99,99,101,115,115,95,116,111,107,101...}" Instead of a parsed JSON object.
My questions:
-
In what format does APIC store the invoke response object?
-
Why is the JSON response represented as a Buffer?
-
Is using a Parse policy the only recommended way to convert the buffer to a JSON object, or is there a direct way in GatewayScript?
I want to understand the expected behavior and best practice for handling backend JSON responses in proxy APIs.
Thanks in advance for any guidance!