API Connect

 View Only
  • 1.  get

    Posted Fri February 16, 2024 06:08 PM

    API Connect context variables

    Ibm remove preview
    API Connect context variables
    List of IBM API Connect context variables that you can reference when defining default parameter values in an assembly operation, or by using the getContext() function when defining a policy.
    View this on Ibm >

    var mypropertyvalue = $(apim-mycatalog-mypropertyname)

    Is this syntax correct to get a catalog variable value as described in the documentation. I tried it in a javascript policy and it returns the much admired "HTTP 500 Internal server" error ? 

    Thanks 

    Mehedi



    ------------------------------
    Mehedi mehedi
    ------------------------------



  • 2.  RE: get

    Posted Fri February 16, 2024 11:18 PM
    Hi, 
    We can get the props as below as well.

      Var props = context.get('api.properties');
       Var prop1 = props.definedCatalogPropertyName;
        Var prop2 = props.definedCatalogPropertyName


    Thx





  • 3.  RE: get

    Posted Sun February 18, 2024 06:56 PM

    Does this work in getting the QA catalog properties for the api,  if  api published to the  DEV catalog and request run in DEV.

    Var props = context.get('api.properties');
       Var prop1 = props.definedCatalogPropertyName; // like say props.QA.mypropertyname 
        Var prop2 = props.definedCatalogPropertyName



    ------------------------------
    Mehedi mehedi
    ------------------------------



  • 4.  RE: get

    Posted Sun February 18, 2024 11:44 PM
    Hi,
    It works for me, we are using at present in our prod systems.
    When ever we publish APIs to specific catalogue , API is available with those catalogue props, which we define in catalogue props in policy section. 






  • 5.  RE: get

    Posted Tue February 20, 2024 09:54 AM

    Looks like we are agreed on  the documentation being in error.  How do we get this info to IBM to update the documentation to be correct ?

    Thanks

    Mehedi



    ------------------------------
    Mehedi Hashir
    ------------------------------



  • 6.  RE: get

    Posted Wed February 21, 2024 10:22 AM

    Clarified by IBM  on a PMR we'd opened. There is an issue with the release of APIM in which the syntax as described in the documentation to get catalog specific properties is not working.   The documentation is not in error.

    Thanks

    Mehedi



    ------------------------------
    Mehedi Hashir
    ------------------------------



  • 7.  RE: get

    Posted Tue February 27, 2024 03:08 PM
    Edited by Steve Linn Tue February 27, 2024 03:13 PM

    Hi Mehedi,

    My two cents on this thread.  In v5(c) you are allowed to modify GatewayScript and XSLT code by having $(varname) in the source code.  There is an API property x-ibm-gateway-sourcecode-resolve-apic-variables (see https://www.ibm.com/docs/en/api-connect/10_reserved_instance?topic=definitions-api-properties) that controls whether this code substitution is allowed which was added because code substitution can open the door for code injection attacks, but as v5 from the beginning allowed this, the default value of this property is true which allows this behavior as to not break existing customers that might depend upon this behavior, but the property provided a mechanism for security minded organizations to disable that behavior.  With the API Gateway, this new gateway service viewed this behavior as a non-starter and you are not allowed to dynamically update your code in this way.   Thus, you would properly in your code use the appropriate get function as is noted in the prior comments.

    Finally, I'll update my post to indicate that the AMU migration utility for v5 customers migrating to the API Gateway will detect any variable replacement, either via {paramname} or $(varname) in source code and will generate an error to notify the customer that this code must be changed since it is not supported in the API Gateway.
    Best Regards,
    Steve



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