API Connect

 View Only
Expand all | Collapse all

Error While Pushing User-Defined-Policy to Catalog Gateway Policies

  • 1.  Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Mon January 23, 2023 08:27 AM
    Edited by Stefen Salvatore Mon January 23, 2023 08:29 AM
      |   view attached
    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
    ------------------------------

    Attachment(s)

    docx
    UDP Error Doc.docx   2.14 MB 1 version


  • 2.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Tue January 24, 2023 09:16 AM
    Hi

    Are you using the correct gateway type for the User defined policy you are using? haven't worked with UDPs in very long time. However, if 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
    ------------------------------



  • 3.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Tue January 24, 2023 10:15 AM
    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
    ------------------------------



  • 4.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Wed February 01, 2023 01:12 AM
    Edited by Stefen Salvatore Wed February 01, 2023 06:49 AM

    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
    ------------------------------



  • 5.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu February 09, 2023 09:44 AM

    Hi, I have the same problem. I'm trying to upload the policies through API Connect v10 but I'm getting that error. I've only been able to upload them via Datapower, did you manage to fix it?

    Thank you very much!



    ------------------------------
    Gonzalo Queipo
    ------------------------------



  • 6.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu February 09, 2023 11:52 AM

    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
    ------------------------------



  • 7.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Wed February 22, 2023 07:22 AM
    Edited by Stefen Salvatore Wed February 22, 2023 07:23 AM

    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
    ------------------------------



  • 8.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Wed February 22, 2023 05:25 PM

    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
    ------------------------------



  • 9.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu February 23, 2023 02:31 AM

    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.



    ------------------------------
    Vyasavardhan Ramagiri
    ------------------------------



  • 10.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu February 23, 2023 08:36 AM

    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
    ------------------------------



  • 11.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu June 29, 2023 03:05 PM
    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
    ------------------------------



  • 12.  RE: Error While Pushing User-Defined-Policy to Catalog Gateway Policies

    Posted Thu July 13, 2023 05:54 PM

    Hi Ashok,

     
    1. Should I configure the gateway-extension along with manifest in cloud manager UI.
    ==> That is one way to deploy your UDP.  The manifest will indicate if the UDP is to be globally deployed or to specific catalogs.  I believe there are also apic CLI commands that can be used as well.
    2. Should I create a YAML file and upload the policy in all the catalogs in API Manager UI
    ==> Your choice.  The policy should be available to those API developers that would need it.
    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
    ==> Within GatewayScript, use context.get('local.parameter') to get a JSON object of all of the UDP properties.  In xslt you can do an apigw:get-variable but note that this will return JSONx which you can then use XPath to get the specific properties you wish.
    4. Accessing API metadata using apic.getContext is not working inside the gatewayscript implementation.
    ==> I'll need some more information on "not working".  What type of error or result are you seeing.  What is variable `apic` and if that is from a require('apim'), the v5 compatibility module, what argument are you providing it, ie, what data from context are you attempting to see.  Can you use a context native function instead?

    Best Regards,
    Steve
     


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