Layer7 API Management

Expand all | Collapse all

How to extract the response headers like status message through layer 7 context variables?

  • 1.  How to extract the response headers like status message through layer 7 context variables?

    Posted Jun 16, 2015 03:11 AM

    Hi

     

    What context variables should we use if we want to extract the response header fields like status message etc. Tried using ${response.http.status-line} but this doesnt seem to be working.

    We basically want to capture the header status message in case of say a 400 bad request. We are able to get the status code (i.e 400) but no the status message (i.e. Bad request). Can you please let us know what context variable to use for that?



  • 2.  Re: How to extract the response headers like status message through layer 7 context variables?

    Broadcom Employee
    Posted Jun 16, 2015 04:45 AM

    Hi, is this in relation to a routing assertion? Did you investigate ${response.http.status} and in case you want to access response headers they are available through ${response.http.header.<headername>} replacing <headername> with the name of your header..



  • 3.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted Jun 16, 2015 05:15 AM

    Yes, this is related to routing assertion. I did try ${response.http.status} and it returns back just the response code (like 400, 500) not the response message.

    I also tried ${response.http.header.status-line} and ${response.http.header.statuscode} but neither seems to be working. Is there an particular header field that would give me back the response message?



  • 4.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted Jun 17, 2015 03:02 AM


    Can you try ${response.mainpart} . This returns the response details. Is this what you are looking for ?

    Can also try ${response.http.allheadervalues} which returns all the header values



  • 5.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted Jun 22, 2015 04:10 AM

    Shashank

     

    ${response.mainpart} would give me the response 'body' but in this case, no response is coming back from the backend service as the connection to the backend failed hence i am forced to extract the error details from the header.

    I tried using ${response.http.allheadervalues} but cant see any header for the error string in that list.



  • 6.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted Jun 26, 2015 11:13 AM

    Mansee,

     

    What makes you think this special http header exists in the first place? There probably just isn't such a header coming from your backend. The http status is not always accompanied with an error description in the payload, that depends on your backend behavior.



  • 7.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted May 22, 2018 09:16 PM

    Hi did you find solution to it? I am also facing same issue. I am able to retrieve the status code 400 but not the status message. Please confirm.



  • 8.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted Feb 02, 2018 12:07 PM

    I have tried using below as Audit Details

    Response:${response.mainpart}
    Response Headers: ${response.http.allHeaderValues}

     

    But do not see a response header 



  • 9.  Re: How to extract the response headers like status message through layer 7 context variables?

    Broadcom Employee
    Posted May 23, 2018 12:11 AM

    Here are the two links to Wiki pages that deal with Messages and Transport Layer context variables. 

     

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

     

    Transport Layer Context Variables - CA API Gateway - 9.3 - CA Technologies Documentation 

     

    These should contain most context variables that would be able to extract data from the response message. The ones that would be most helpful tonsh03 has pointed out, but any variable that starts with <target> can be used as response. 

     

     

    Francois Lascelles is correct is saying that the backend may not be send you a header with the information you seek. It would be best to confirm with whoever owns the backend what information is being sent back after a failure (i.e 400 or 500 HTTP response). 



  • 10.  Re: How to extract the response headers like status message through layer 7 context variables?

    Posted May 23, 2018 12:41 AM

    Hi,

     

    I am using SoapUi to test the interface, when I hit the backend system (ESB) directly, I receive:

     

    HTTP/1.1 451 Invalid Field
    Server: Apache-Coyote/1.1
    Content-Encoding: gzip
    Content-Type: application/json;charset=UTF-8
    Content-Length: 139
    Date: Wed, 23 May 2018 04:36:42 GMT

     

    and the header tab under response in soap ui shows:

     

     

    DateWed, 23 May 2018 04:36:42 GMT
    Content-Length139
    #status#HTTP/1.1 451 Invalid Field
    Content-Encodinggzip
    Content-Typeapplication/json;charset=UTF-8
    ServerApache-Coyote/1.1

     

    But hitting the CA API gateway which is routing to same ESB service, I get

     

    HTTP/1.1 451
    Server: Apache-Coyote/1.1
    Content-Encoding: gzip
    Content-Type: application/json;charset=UTF-8
    Content-Length: 139
    Date: Wed, 23 May 2018 04:36:42 GMT

     

    And the header tab under response in SoapUi shows:

    DateWed, 23 May 2018 04:36:42 GMT
    Content-Length139
    #status#HTTP/1.1 451
    Content-Encodinggzip
    Content-Typeapplication/json;charset=UTF-8
    Server

    Apache-Coyote/1.1

     

    So i am not receiving the status-line/message along with the status code 451. I am missing Invalid Field which I need to present to the client.