Original Message:
Sent: Thu June 29, 2023 03:05 PM
From: Ashok Beshra
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi Steve / Vyas...
I am trying to implement a similar kind of UDP in IBM API Connect V10.0.5.3 for logging activity. My requirement is that,
1. Develop a UDP to capture metadata details(using GatewayScript policy) when an API is implemented and build an XML.
2. Use urlopen function inside the GatewayScript policy to 'POST' to a HTTP URL (basically a MPGW service lisenting on another datapower gateway device)
3. Develop the MPGW service to insert the XML API metadata in Oracle database.
I cannot directly use XSLT in my UDP to insert API metadata into Oracle Database as our Datapower API Gateway is exposed in public and in a different zone. Please let me know on the below for deploying a global scope UDP
1. Should I configure the gateway-extension along with manifest in cloud manager UI.
2. Should I create a YAML file and upload the policy in all the catalogs in API Manager UI
3. The UDP has some properties which should be accessible in the gateway script code. How to access the property and in the gatewayscript policy implementation
4. Accessing API metadata using apic.getContext is not working inside the gatewayscript implementation.
Please help on the queries w.r.t UDP implementation, Thanks
------------------------------
Ashok Beshra
Original Message:
Sent: Thu February 23, 2023 08:36 AM
From: Steve Linn
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi Vyasavardhan,
As noted in my previous post for issue 3, apigw:get-variable('message.original.headers'), the JSON returned is of the form
{"header1": "header1-value", ... "headern": "headern-value"}
but objects returned by the get-variable function will return JSONx, so again use the jsonxtojson.xsl to get a JSON string
<xsl:variable name="HTTPHeadersJSON" select="dp:transform('store:///jsonx2json.xsl', $HTTPHeaders)" />
I don't understand UDP 'only values'
to understand what that code is doing differently from the code you pasted. What your UDP is inserting in just the values of the JSONx, perhaps it is simply doing a xsl:value-of the JSONx nodeset to produce that result. If the raw json string is not sufficient, then you'll need to build whatever is needed by implementing a xsl transformation template that will recursively iterate through the JSONx and will produce some concatenation of name=value<delimiter>name1=value ... etc string.
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Thu February 23, 2023 02:31 AM
From: Vyasavardhan Ramagiri
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi @Steve Linn
Sorry for the above code mistake. We have implemented using correct syntax only for issue 2. we have used colon only but used small v in variable.
and now When Iam inserting headers in Database using Code in Assembly using following code snippet.
<xsl:variable name="HTTPHeader">
<xsl:choose>
<xsl:when test="$LogPointID = 'OrigRequest'">
<xsl:copy-of select="apigw:get-variable('message.original.headers')"/>
</xsl:when>
<xsl:when test="$LogPointID ='FinalResponse'">
<xsl:copy-of select="apigw:get-variable('Final.headers')"/>
</xsl:when>
<xsl:otherwise>
<xsl:message dp:priority="error">
<xsl:text>otherwise condition:::</xsl:text><xsl:copy-of select="'select the LogPointID'"/></xsl:message>
<xsl:copy-of select="'select the LogPointID'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<argument type="SQL_VARCHAR" mode="INPUT">
<xsl:copy-of select="$HTTPHeader"/>
</argument>
It is inserting data in Database but the same code when used.
in Code (Assembly):
Inserts:
<json:object xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx"><json:string name="Host">uatdevelopment.prontefflabs.com:9443</json:string><json:string name="content-length">9</json:string><json:string name="sec-ch-ua">"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"</json:string><json:string name="x-ibm-client-id">fbb59ddb80e65b1e9eb2432786d4343d</json:string><json:string name="sec-ch-ua-mobile">?0</json:string><json:string name="user-agent">Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36</json:string><json:string name="content-type">application/json;charset=UTF-8</json:string><json:string name="accept">application/json, text/plain, */*</json:string><json:string name="apim-debug">true</json:string><json:string name="sec-ch-ua-platform">"Windows"</json:string><json:string name="origin">https://apiuat-manager-ui.prontefflabs.com</json:string><json:string name="sec-fetch-site">same-site</json:string><json:string name="sec-fetch-mode">cors</json:string><json:string name="sec-fetch-dest">empty</json:string><json:string name="referer">https://apiuat-manager-ui.prontefflabs.com/</json:string><json:string name="accept-encoding">gzip, deflate, br</json:string><json:string name="accept-language">en-US,en;q=0.9</json:string></json:object>
using UDP:
Inserts:
uatdevelopment.prontefflabs.com:94439"Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"fbb59ddb80e65b1e9eb2432786d4343d?0Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36application/json;charset=UTF-8application/json, text/plain, */*true"Windows"https://apiuat-manager-ui.prontefflabs.comsame-sitecorsemptyhttps://apiuat-manager-ui.prontefflabs.com/gzip, deflate, bren-US,en;q=0.9I need the data to be inserted into database is name and values of headers, but when using UDP 'only values' are inserting into it.
Thanks in advance!!!
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Wed February 22, 2023 05:24 PM
From: Steve Linn
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi Vyasavardhan,
Issue 1:
I don't have an explanation for this difference in behavior. The xsl variable OrigRequestPayload has as its value the XML document that is returned from the extension function, versus your second instance that is using the extension function results (the same XML document) directly in the xsl:copy-of instead of the xsl variable reference. Off the top of my head I'd expect both to return the same result. The behavior is almost as if the first instance was using a xsl:value-of and not a xsl:copy-of. I would use the one that meets your requirements. I'd open a PMR on the other instance if you would like to see that working like the one you chose to use. It may or may not be a product issue, but the appropriate developer could take a detailed look to determine why this would be happening and if it is a defect or not.
Issue 2:
I answered this in your other thread, but essentially you need a colon instead of a period separating the namespace prefix and the function name, and the apim:getVariable extension function is using a capital V not lower case.
Issue 3:
If you wanted to manipulate the JSON payload, in an xslt you'd need to do an XML transformation which is why the apigw:get-variable('request.body') is returning JSONx, an XML representation of the JSON. You can convert that JSONx to a String by using
<xsl:variable name="updatedPayload" select="dp:transform('store:///jsonx2json.xsl', $payloadJSONx)" />
which will provide the updatedPayload variable with a string.
Regards,
Steve
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Wed February 22, 2023 07:21 AM
From: Vyasavardhan Ramagiri
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi @Steve Linn
We are facing some abnormal issues while using UDP which is created using a YAML for storing the log details into an Oracle Database.
Issue No 1:
We are trying to store original request payload into a variable as mentioned below.
" <xsl:variable name="OrigRequestPayload" select="apigw:get-variable('request.body')"/> "
Sample Request Body: <name>Steve Linn</name>
when printing in logs: <name>Steve Linn</name>
But storing in Database as: Steve Linn
But the same code without UDP is Placing the exact data into Database(<name>Steve Linn</name>).
In UDP, when a variable reference is used in code of UDP it is picking only value-of but when Iam directly retrieving, it is working.
Issue No 2:
We are trying to store some context variable into a variable as mentioned below.
look at these two lines.
" <xsl:variable name="OrigRequestPayload" select="apim.getContext('request.body')"/> "
"xsl:variable name="OrigRequestPayload" select="apim.getvariable('request.body')"/>"
Sometimes apim. is not giving the Response but apigw: is giving the Response in UDP and Error Global Policy also and as well as When I used in code in Assembly also. Why is this happening?
" <xsl:variable name="OrigRequestPayload" select="apigw:get-variable('request.body')"/> " is giving the Response.
Issue No 3:
Iam sending a JSON request and capturing into a variable and trying to store in Database. I can be able to store but the JSON is converting into XML. (when trying through UDP)
Request Body:
{"name": "smith"}
Request Body Storing in the Database:
<json:object xsi:schemaLocation="http://www.datapower.com/schemas/json jsonx.xsd"
xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<json:string name="name">smith</json:string>
</json:object>
Help me regarding solving this problem.
Thanks in Advance!!
------------------------------
Vyasavardhan Ramagiri
Original Message:
Sent: Thu February 09, 2023 11:52 AM
From: Steve Linn
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi Vyasavardhan,
As Charles points out, a v5 UDP must be associated with the gateway via a gateway-extension.zip file using the CMC for that Gateway in the CMC Topology. That zip file would include your v5 UDP zip and a manifest.json file that would specify the v5 emulation framework is to be deployed and would specify a files section that would reference the v5 UDP zip file with a type of policy-v5. The Catalog UI to upload a UDP is only for a v10 API Gateway UDP, which is why you're getting the error. See the link Charles provided to build the manifest.json required.
Best Regards,
Steve Linn
------------------------------
Steve Linn
Senior Consulting I/T Specialist
IBM
Original Message:
Sent: Wed February 01, 2023 01:12 AM
From: Vyasavardhan Ramagiri
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
I've followed IBM docs
https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=apdag-defining-packaging-publishing-catalog-scoped-policy-api-gateway
this is the error iam getting after creating assembly function
please guide me where iam going wrong.
Thanks in Advance!!
------------------------------
Vyasavardhan Ramagiri
DP/APIC Developer
Original Message:
Sent: Tue January 24, 2023 10:15 AM
From: CHARLES COBLE
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
To follow up on Niki's point, there is a way to push V5 policies to an Datapower API Gateway but it has to be done via an extension with a manifest. This will use the V5E framework so that the policy doesn't have to be rewritten in native format. KC: https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=gateway-extensions-manifest. You would use the policy-v5 type. Note there is a performance hit for using V5E instead of native.
------------------------------
CHARLES COBLE
Original Message:
Sent: Tue January 24, 2023 08:56 AM
From: Niki Heyligen
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi
Are you using the correct gateway type for the User defined policy you are using? I haven't worked with UDPs in a very long time. However, if I recall properly, the only gateway that accepts UDPs based on an MPG processing rule is the v5c gateway (DataPower gateway). The native gateway (Datapower API Gateway) only supports UDP's based on the Assembly feature of DataPower.
More info:
v5c gateway: https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=policy-implementing-your
native gateway: https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=policies-authoring-datapower-api-gateway
But as I've already mentioned, it's been a while since I used UDPs in APIC.
something worth considering is using the APIC CLI toolkit. It could provide you with more specific details regarding the error.
Regards
Niki
------------------------------
Niki Heyligen
Original Message:
Sent: Mon January 23, 2023 08:26 AM
From: Vyasavardhan Ramagiri
Subject: Error While Pushing User-Defined-Policy to Catalog Gateway Policies
Hi All,
I'm Here for a help regarding user-defined-policies in API Connect V10.
So the case is :
I want to create a UDP using Datapower Rule. So that i've create AAA processing rule in Datapower which uses default xml file provided in DP to Authenticate users. As my policy rule worked fine in a sample MPG service I exported the processing rule congifuration which is attached below for your understanding.
But after packing the file when iam trying to push the zip to policies it is throwing error with code : 0x08900010a and message as " invalid"
please let me know where iam going wrong and provide me a detailed info to achieve this.
Note : for the complete clarification purpose a word file consisting all the details about this issue is attached below. Please Go through it and treat this as an emergency.
Thanks in Advance!!!
------------------------------
Vyasavardhan Ramagiri
------------------------------