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.

 View Only
  • 1.  Html responce was not captured through message body

    Posted Tue July 11, 2023 11:36 AM

    Hi all,

    We are trying to log the request and response into Database, It is working for JSON/XML but not captured the backend response when it's Content-Type: text/html, I was checked through trace also its showing in message.body but when we print in logs and database it won't come.

    Please find the related screenshots.

    We facing below error also coming in logs without writing into logs and we are not seen xslt code also, if having the error in code it should come stylesheet error.  Please help me on this two issues.

    "illegal character '>' at offset 54 of http://"



    ------------------------------
    kandula nagababu
    ------------------------------


  • 2.  RE: Html responce was not captured through message body

    Posted Tue July 11, 2023 05:24 PM

    Hi Kandula,
    That error would appear to be coming from a parse policy? Please confirm, but if so, there is an issue, fixed only in DataPower 10.5.0.x, where a parse policy with content type will default to a "detect" parse mode, and seeing the < first character it will attempt to parse the html as XML.  That of course will almost always fail and cause your API request to fail.  If you're using DP 10.0.1.x, I'd suggest wrapping your parse policy with a switch that checks for message.headers.content-type to not  be text/html.  As to why that html string which is in context is not showing up in your analytics logs, I would think you would open a PMR for that.  Does it exhibit this behavior for text/plain, ie, other non JSON/XML payloads?

    Regards,
    Steve Linn



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------



  • 3.  RE: Html responce was not captured through message body

    Posted Wed July 12, 2023 11:21 AM

    Hi Steve,

    Currently we are using version is 10.5.0.3 still issue was persisted and we observed you said points also in my Environment.

    When having the Content-Type text/plain also its not captured the data into logs and Database as well.

    we don't have access to open PMR. Can you tell me the difference between getting context variables values using different syntax in xslt as shown below.

    <xsl:message dp:priority="error"><xsl:text>apimvar payload:::</xsl:text><xsl:copy-of select="apim:getVariable('message.body')"/>
    <xsl:text>getContext payload:::</xsl:text><xsl:copy-of select="apim:getContext('message.body')"/>
    <xsl:text>apigwgetvar payload:::</xsl:text><xsl:copy-of select="apigw:get-variable('message.body')"/></xsl:message>



    ------------------------------
    kandula nagababu
    ------------------------------



  • 4.  RE: Html responce was not captured through message body

    Posted Thu July 13, 2023 04:11 PM

    Hi Kandula,
    apim: is the v5 compatibility xsl that you can import into your xsl, whereas apigw: is a native v10 extension function.  The should return the same values for message.body, although the apim module internally will be using the apigw native extension functions so you're adding some additional latency at the expense of having the compatibility module to return the same as it did in v5.  I have not tested this myself, but I would expect there may be some minor differences in the returned values for request.parameters.name with respect to encoded characters.

    As for the analytics captured request_body and response_body, I know v5 (and thus v5 compatible) gateways would only capture XML and JSON content.  As for the API Gateway, I did a simple test case and I am seeing text/plain and text/html request and response documents in the analytics record.  Of course you need to have your activity-log settings for the API configured to log payload in the successful case.

    Best Regards,
    Steve



    ------------------------------
    Steve Linn
    Senior Consulting I/T Specialist
    IBM
    ------------------------------