API Connect

API Connect

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#API Connect
#Applicationintegration
#APIConnect
 View Only
  • 1.  switch policy with custom condition in native gateway

    Posted Tue February 28, 2023 10:27 AM

    We are migrating one of our API from v5 compatible gateway to api gateway.  

    in my v5 compatible API i have set a variable as Boolean and i m setting value using apim.setvariable

    in v5 compatible switch has if condition like apim.getvaribale('login') == true 

    in my new API i have set a variable as Boolean and i m setting value using context.set

    in api gateway switch policy i wrote  (if context.get('login') = true)  but validation failed.

    so how do i write a custom condition which reads local variable ? 



    ------------------------------
    Rajesh Solanki
    ------------------------------


  • 2.  RE: switch policy with custom condition in native gateway

    Posted Wed March 01, 2023 09:50 AM

    Hi Rajesh,
    v5 and v5 compatible use GatewayScript in the conditionals, whereas the API Gateway uses JSONata.  You'd simply use

    login = true

    where login is your variable.  You don't need to specify code to get the variable, just the variable name is assumed to need to be pulled from the context.

    Regards,
    Steve



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



  • 3.  RE: switch policy with custom condition in native gateway

    Posted Thu March 02, 2023 06:47 PM

    Thanks a lot ! 



    ------------------------------
    Rajesh Solanki
    ------------------------------



  • 4.  RE: switch policy with custom condition in native gateway

    Posted Wed October 11, 2023 09:23 AM

    That would be a very useful information to be found in the switch / variable references or other documentation IBM might have. I swear I looked everywhere before reaching this thread:
    - https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=definitions-variable-references-in-api-connect
    - https://www.ibm.com/docs/en/api-connect/10.0.1.x?topic=switch-writing-condition-scripts-datapower-api-gateway
    - https://www.ibm.com/docs/en/api-connect/10_reserved_instance?topic=aplc-using-context-variables-in-gatewayscript-xslt-policies-datapower-api-gateway
    - https://www.ibm.com/docs/en/api-connect/10_reserved_instance?topic=constructs-switch

    I am so sorry to say that the API Connect and Datapower documentation is a bit lame. It is written by somebody who has knowledge of the product therefore a lot of important bits and pieces are missing, because for the writter... it just make sense. For users... it won't. 



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