API Connect

 View Only
Expand all | Collapse all

Cannot able to Define Catalog specific property values in API Properties

  • 1.  Cannot able to Define Catalog specific property values in API Properties

    Posted Wed March 09, 2022 02:11 AM
    I want to put domain of target url in Catalog define properties as it is volatile n changes frequently so I am try to use the property in API to invoke endpoints but these property isn't working out.
    I followed these for ref. -
    Defining Catalog specific property values
    Setting API properties


    ------------------------------
    Anurag Gupta
    ------------------------------


  • 2.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Thu March 10, 2022 01:40 PM
    Hi Anurag,

    How exactly did you try it? Can you post snippet of how it was defined in the API, how it was used in the API, as well as catalog names/titles you have?​

    ------------------------------
    SUMANTO Biswas
    ------------------------------



  • 3.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Fri March 11, 2022 03:15 AM

    AFAIK for 2018, catalog properties are applied only when you publish API with current property value, and not changing when you change property value. So it isn't really dynamic.

    I assume you expect properties values to change frequently, so you'll need to republish all APIs on property changes.

    But I clouldn't find this information in documentation right now, it's from hands-on experience.Somebody plz correct me, if I'm wrong.



    ------------------------------
    Denis Migulin
    ------------------------------



  • 4.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Tue March 15, 2022 11:39 PM
    @Denis Migulin you are correct - you have to stage/re-publish the Product​ containing the API again for API properties changes to take effect.

    I will create an internal docs issue to update the API Connect documentation - thank you for checking.

    ------------------------------
    SUMANTO Biswas
    ------------------------------



  • 5.  RE: Cannot able to Define Catalog specific property values in API Properties

    IBM Champion
    Posted Wed March 16, 2022 07:34 AM
    Unfortunately, that's a big pain point for some implementations. Unless you call an external service or use extensions, there is no way currently in the product to provide dynamic config values.


  • 6.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Fri May 27, 2022 07:51 AM
    Hi Denis,

    After Changing the catalog properties, we can republish the product still better option than changing target url individually as all the APIs inside product follows same domain whose version is changing(PFA of screenshot in which catalog property is defined where I am trying to change version).
    But catalog property values isn't accessible to me inside API.
    How is defined catalog property in my API -(cat_1.0.0.yaml)
    properties:
        empty: {}
    catalogs:
        Sandbox:
           properties: {}

    where empty is property define inside catalog named sandbox.
    and also what reference variable is required to access value of same property.

    ------------------------------
    Anurag Gupta
    ------------------------------

    Attachment(s)

    yaml
    cat_1.0.0.yaml   707 B 1 version


  • 7.  RE: Cannot able to Define Catalog specific property values in API Properties

    IBM Champion
    Posted Fri May 27, 2022 09:24 AM
    I didn't quite understand the second part of your questions, but you can access your catalog property inside your API flow by using $(catalog-var-name)
    Use a set-variable policy to assign $(catalog-var-name) value to a new context variable e.g: target-url. Then use target-url context variable in your Invoke.


  • 8.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Fri May 27, 2022 04:08 PM
    Hi Romil,

    The name of catalog is 'sandbox' and variable name is 'empty' so reference i tried to get value $(sandbox-empty)/$(api.properties.empty)/$(apim-sandbox-empty) but any of them doesn't return value the which i defined in catalog.

    ------------------------------
    Anurag Gupta
    ------------------------------



  • 9.  RE: Cannot able to Define Catalog specific property values in API Properties
    Best Answer

    IBM Champion
    Posted Fri May 27, 2022 04:15 PM
    You don't have to specify the catalog name if your API is deployed/consumed in that catalog. Just use variable name : $(empty)



  • 10.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Fri May 27, 2022 04:28 PM
    Thanks It worked out for me. Thanks @Romil Garg , Basically we don't have to do anything just have to use access it, i was trying to add some catalog properties in API because of that it always show​ unfined.


    ------------------------------
    Anurag Gupta
    ------------------------------



  • 11.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Tue January 24, 2023 01:38 PM
      |   view attached
    @Anurag Gupta can you post your api yaml after the issue was resolved, i am facing the same problem. Here is my yaml attached. I am getting undefined when i try to run the gateway script.


    ------------------------------
    jayaseelan lourdusamy
    ------------------------------

    Attachment(s)

    yaml
    memberdemo.yaml   14 KB 1 version


  • 12.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted Tue January 24, 2023 02:21 PM
    @Romil Garg can you check the attached memberdemo.yaml and comment. I am still hitting the undefined when i try to pull my values from the catalog properties. ​

    ------------------------------
    jayaseelan lourdusamy
    ------------------------------



  • 13.  RE: Cannot able to Define Catalog specific property values in API Properties

    Posted 8 days ago
    Edited by Adrian Ruben Dogar 8 days ago

    This thread is important so I am trying to provide a simple swagger that will point everyone in the correct directions and also will show why we are stumbling so much on this issue with a very easy solution. It cannot be accessed directly inside the gatewayscript (with context.get() or apim.getvaraible()). You need to access it first with set-variable via the $(var) notation. There you can assign it to any other existent/new context variable and use the latter one in the gollowing gatewayscripts.

    swagger: '2.0'
    info:
      title: test
      x-ibm-name: test
      version: 1.0
    basePath: /test
    x-ibm-configuration:
      cors:
        enabled: true
      gateway: datapower-api-gateway
      type: rest
      phase: realized
      enforced: true
      testable: true
      assembly:
        execute:
          - set-variable:
              version: 2.0.0
              actions:
                - set: t.one
                  value: Bumblebee
                  type: string
                - set: a
                  value: $(avenger)
                  type: string
          - gatewayscript:
              version: 2.0.0
              title: gatewayscript
              source: context.set("t.two", "Optimus Prime");
          - set-variable:
              version: 2.0.0
              actions:
                - set: p
                  value: $(pokemon)
                  type: string
                - set: a
                  value: $(avenger)
                  type: string
          - gatewayscript:
              version: 2.0.0
              title: gatewayscript
              source: |-
                let body = {
                  "pokemon_1": context.get("p"),
                  "pokemon_2": context.get("pokemon"),
                  "transformer_1": context.get("t.one"),
                  "transformer_2": context.get("t.two"),
                  "avenger_1": context.get("a"),
                  "avenger_2": context.get("avenger")
                }
    
                context.message.header.set('Content-Type', 'application/json'); 
                context.message.body.write(body);
      properties:
        avenger:
          value: Iron Man
          encoded: false
      application-authentication: {}
      activity-log:
        enabled: true
        success-content: activity
        error-content: payload
    paths:
      /:
        get:
          responses:
            '200':
              description: success
              schema:
                type: string
    securityDefinitions: {}
    security: []
    schemes:
      - https
    produces:
      - application/json
    consumes:
      - application/json
    

    It will produce the following output:

    {
        "pokemon_1": "Pikachu",
        "pokemon_2": null,
        "transformer_1": "Bumblebee",
        "transformer_2": "Optimus Prime",
        "avenger_1": "Iron Man",
        "avenger_2": "Iron Man"
    }


    Of course, you´ll need to have the `pokemon` property set up in the Catalog (web API Manager) before publishing the API: 


    The fact that "pokemon_2" is failing and the fact that you create the catalog property after publishing the API, are the common reasons for users to fail on this feature. 

    Kind regards, 


    ------------------------------
    Adrian Ruben Dogar
    ------------------------------