API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  API Connect

    Posted Tue December 12, 2023 04:01 PM

    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
    ------------------------------



  • 2.  RE: API Connect

    Posted Wed December 13, 2023 01:44 AM

    If you ever get issues like that in web based test tools but it works from the command line then the answer is always CORS.

    Make sure you have enabled CORS in your api and you do not have any OPTIONS operations as they will interfere.



    ------------------------------
    Chris Dudley
    ------------------------------



  • 3.  RE: API Connect

    Posted Thu January 04, 2024 04:27 PM

    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
    ------------------------------



  • 4.  RE: API Connect

    Posted 2 days ago

    You should go to the Activity log and choose the payload option in Success Response

    Path for Activity Log: "Getaway Tap / Activity Log"



    ------------------------------
    Abdelazim Elkhole
    Integration Developer
    Envnt
    Riyad
    0508866204
    ------------------------------