DataPower

DataPower

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
Expand all | Collapse all

forming json message in xslt to use in dp:url-open call

  • 1.  forming json message in xslt to use in dp:url-open call

    Posted Tue September 29, 2020 06:03 PM

    Hi,

    I need to call the cloud database with json formatted request. I have tried below one.

    <dp:url-open target="https://{hostname}/dbapi/v4/sql_jobs" http-method="post" http-headers="$headers" ssl-proxy="client:ssl-client-profile" response="responsecode">

    <xsl:copy-of select="concat('{ &quot;commands&quot; : &quot;insert into IEBX.NON_REPO_LOGS(device_name) values(\'123\')&quot;}')" />

    </dp:url-open>

    in values section, i have tried passing value as 123 / '123' and other ways but none worked. At datapower, the request is failing with error - filename.xsl:25: Operator expected.

    not sure how to pass values in the statement. If anyone come across such issue, please reply here.



    #DataPower
    #Support
    #SupportMigration


  • 2.  RE: forming json message in xslt to use in dp:url-open call

    Posted Thu October 01, 2020 09:15 AM

    hello

    try this

    <dp:url-open target="https://{hostname}/dbapi/v4/sql_jobs" http-method="post" http-headers="$headers" ssl-proxy="client:ssl-client-profile" response="responsecode">

    <xsl:variable name="json">

    <xsl:text>{"commands" : "insert into IEBX.NON_REPO_LOGS(device_name) values(\"123\")"}</xsl:text>

    </xsl:variable>

    <xsl:copy-of select="$json"/>

    </dp:url-open>



    #DataPower
    #Support
    #SupportMigration


  • 3.  RE: forming json message in xslt to use in dp:url-open call

    Posted Thu October 01, 2020 09:15 AM

    Sorry, it's better

    <dp:url-open target="https://{hostname}/dbapi/v4/sql_jobs" http-method="post" http-headers="$headers" ssl-proxy="client:ssl-client-profile" response="responsecode">

    <xsl:variable name="json">

    <xsl:text>{"commands" : "insert into IEBX.NON_REPO_LOGS(device_name) values(\"123\")"}</xsl:text>

    </xsl:variable>

    <xsl:value-of select="$json" disable-output-escaping="yes"/>

    </dp:url-open>



    #DataPower
    #Support
    #SupportMigration


  • 4.  RE: forming json message in xslt to use in dp:url-open call

    Posted Thu October 01, 2020 09:21 AM

    Hi David,

    I tried above one which is for static value but for dynamic values containing " in it throwing invalid json format. And I need to load with soap message which has namespaces. So I serialized the soap message and replaced the " to \" using recursive function so that the json is well formed. Now its working fine.

    Thq for your response.



    #DataPower
    #Support
    #SupportMigration