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

    Posted 03/28/23 09:18 PM

    Hi,

    I want to use a switch based on request.path variable.

    So far I validate the $contains expression but whe I use:

    • $contains(request.path, "xpto")

    Or something similar does not work.

    Can someone explain me how I can do this?

    Thanks in advance.



    ------------------------------
    Filipe Ventura
    ------------------------------


  • 2.  RE: Switch policy

    Posted 03/29/23 03:00 PM

    Hi Filipe,
    Your $contains function looks fine.  Perhaps you could provide your entire switch function for analysis.  Your request.path starts with your API base path, so I'd assume one of your paths does have the string xpto, otherwise, please confirm the version of the switch policy that you're using.  Do you have access to the DataPower appliance? If so, place the logging level at debug and see if there are any logs associated with the switch policy.

    Best Regards,
    Steve



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



  • 3.  RE: Switch policy

    Posted 03/29/23 03:37 PM
      |   view attached

    Hi Filipe,
    A colleague of mine did a simple API using the $contains() function in a switch and it works fine.  I've attached it for your review.
    Regards,
    Steve



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

    Attachment(s)

    yaml
    switch_test_yaml.yaml   1 KB 1 version