API Connect

 View Only
Expand all | Collapse all

How to Read policy property in the gatewayscript code(catalog scoped custom policy in nativeapigateway)

  • 1.  How to Read policy property in the gatewayscript code(catalog scoped custom policy in nativeapigateway)

    Posted Wed December 01, 2021 08:56 AM
    Hello All,

      I am trying to refer the below link that talks about how to create catalog scoped custom policy in Datapower API Gateway. Now I wanted to know how to read the policy input property values in the assembly section(like gatewayscript code). I dont think it is mentioned anywhere in the knowledge center if I am not wrong.


    Defining and packaging a Catalog scoped user-defined policy for the DataPower API Gateway

    I tried the below code, but it didn't work. Appreciate your help and support in this regard. thanks!

    var apim = require('apim');
    var props = apim.getPolicyProperty();
    var field1= props.properyname1;
    var field2= props.properyname1;
    var requestJson ={};
    requestJson["field1"]=field1;
    requestJson["field2"]=field2;
    context.message.body.write(requestJson);

    ------------------------------
    Srinivas Poram
    ------------------------------


  • 2.  RE: How to Read policy property in the gatewayscript code(catalog scoped custom policy in nativeapigateway)

    Posted Thu December 02, 2021 03:55 AM
    Edited by Pierre Richelle Thu December 02, 2021 03:55 AM
    Hello,

    In the sample that I have made, I have used (https://github.com/prichelle/apicv10-UDP/blob/main/assets/mq-invoke/mq-invoke/mq-invoke-code.js).

    var
    parameterName = context.get('local.parameter.<parameterName>');

    Hope this help.


    ------------------------------
    Pierre Richelle
    IBM Hybrid Cloud Integration Specialists
    IBM
    +32474681892
    ------------------------------



  • 3.  RE: How to Read policy property in the gatewayscript code(catalog scoped custom policy in nativeapigateway)

    Posted Thu December 02, 2021 04:24 PM

    Hi Srinivas,
    I believe this is a product defect where the apim v5 compatibility module's getPolicyProperty function was not getting the policy properties of the user defined policy but instead was trying to get the policy properties of the GatewayScript action within the UDP that was attempting the apim.getPolicyProperty().  As pointed out, context.get('local.parameter.<name>') is your workaround, and a fix for apim.getPolicyProperty() will be available in the next release.

    Regards,

    Steve



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