Hi Shubham,
How are you attempting to print the successful response in the gateway logs? A GatewayScript console.log of context.get('message.body')
? What populates message.body
in the context? perhaps an invoke policy response, and if so, do you have buffering disabled (which is the default). If buffering is disabled, the payload is steamed which means you will not see it in the context, so the context.get will return a null. It could very well be that your GatewayScript action is executing while the invoke response payload is still being read, which is the whole purpose of streaming to provide that performance benefit of only pausing for data being read off the wire until it is required. The approach to getting streamed payloads such that you can access them in your API code would be to either 1) add a parse policy after the invoke policy. This will read the entire payload for purposes of parsing it and in doing so message.body will be populate so the context.get will now provide a result that isn't null. 2) You will need to get message.body in your GatewayScript code using the context.message.body.readAsBuffer function. See https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=aplc-using-context-variables-in-gatewayscript-xslt-policies-datapower-api-gateway for some simple examples of this function. The readAsBuffer function will also read all of the data off of the stream. You can then use the buffer returned in the asynchronous function and log that to the DataPower console.
Best Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
------------------------------
Original Message:
Sent: Tue December 12, 2023 05:18 AM
From: SHUBHAM RUDRAWAR
Subject: API Connect
Hi All,
I've developed one API for which I'm getting blank Success responses on the API manager and portal. For the error scenario, I'm getting the expected error in response. I tried to print the success response in gateway logs, there I'm getting "null" in the response.
I have tested the same API on Postman there I'm getting the expected response.
------------------------------
SHUBHAM RUDRAWAR
------------------------------