API Connect

 View Only
Expand all | Collapse all

Getting API Manager Defined Catalog Properties using Gateway Script

  • 1.  Getting API Manager Defined Catalog Properties using Gateway Script

    Posted Thu April 27, 2023 01:22 PM
      |   view attached

    I defined a catalog property using the API Manager User Interface:

    I created a simple test API (attached) that tried to access the value in 2 ways:

    a.  Using a set-variable policy and using the $(test-apim-catalog-property) to access the value which was successful.

    b.  Using a gateway script using a context.get('test-apim-catalog-property') to access the value which failed.

    Question:  How can I access the Catalog Property value defined in the API Manager from a GatewayScript policy?



    ------------------------------
    Steve Ruscik
    ------------------------------


  • 2.  RE: Getting API Manager Defined Catalog Properties using Gateway Script

    Posted Fri May 05, 2023 09:16 AM

    Hi Steve,
    Catalog properties are resolved at publish time, so in your case, a GatewayScript policy with context.get('test-apim-catalog-property') will not work as that property in not in the context.  What you will need to do is to first have a set-variable policy that will create a context property (you could use the same name) where the property value is specified as a variable replacement, ie $(test-apim-catalog-property').  At publish, that catalog property will be resolved, so what the Gateway will receive is a set-variable to set the variable to the catalog property value.  Your GatewayScript policy would then use the variable created by the set variable policy.

    Best Regards,

    Steve



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