Layer7 API Management

 View Only
  • 1.  response.mainpart is null

    Posted Jul 21, 2016 10:23 PM

    I am trying to send the response back to requester using Return Template Response to Requestor Assertion and returning ${response.mainpart} but it is empty as shown in service debugger window as "mainpart = null" but in fact the backend is sending a response as shown in the postman(left side of the screenshot).

    I am able to get the response when i directly use Route via HTTP Assertion without using Return Template Response to Requestor Assertion

     

    Is this because of the Content-Type "application/vnd.kafka.binary.v1+json" ? Is there an extra configuration on Gateway which needs to be done to support this MIME Type ?

     

     

    Screen Shot 2016-07-21 at 6.48.32 PM.png

     

    This is similar to Mysterious empty response message raised by Nicolas_Afonso , haunting me now even with correctly set Content-Type header

     

    I have already tried setting io.httpDefaultContentType cluster wide property to application/vnd.kafka.binary.v1+json without any success in getting the backend response.

     

    FYI Gateway version used is : 8.3

     

    Regards,

    Ganesh Reddy



  • 2.  Re: response.mainpart is null
    Best Answer

    Posted Jul 21, 2016 10:35 PM

    Since its a multipart message you need to use  ${response.parts[0]}

    maybe .mainpart at the end. Let me know if this works for you. Been a while since I dealt with multipart messages in the gateway.



  • 3.  Re: response.mainpart is null

    Posted Jul 28, 2016 03:50 PM

    Thanks bloan03

    Indeed it solved by using ${response.parts[0]} but how do i differentiate for a normal response to a multipart?



  • 4.  Re: response.mainpart is null

    Posted Jul 28, 2016 07:23 PM

    The answer is in the question. If the response is a MIME type then you use ${response.parts}. If the response is just a normal body message then you can just use ${response.mainpart}.

     

    Message Layer Context Variables - CA API Gateway - 9.0 - CA Technologies Documentation



  • 5.  Re: response.mainpart is null

    Broadcom Employee
    Posted Jul 22, 2016 08:10 AM

    Hi Ganesh,

     

    My problem was different : the server did not send me Content-Type along its responses !

    In such case, the gateway did not know how to handle them ...

     

    If you're dealing with a kafka rest api, try to enforce application/json content type by adding a "Accept: application/json" header. Is it possible that Gateway does not support this MIME type.