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.

 View Only
  • 1.  Get the value of path parameter and pass it to invoke URL

    Posted Mon January 09, 2023 11:07 AM

    Hello! I would like to ask how you can get the value of a declared path parameter and pass it to the invoke URL in Gateway Policy.

    For example, I created a GET operation with a path

    /users/{user}

    wherein {user} is the declared parameter located in the path. Is it possible that when the APIC endpoint is invoked it will get the value of {user} from that endpoint and pass it on to the URL such that it will be invoked in our microservice as

    $(host-url)/users/{user}

    Appreciate any help you can extend!



    ------------------------------
    Best regards,
    Michael Emil Rivera
    ------------------------------


  • 2.  RE: Get the value of path parameter and pass it to invoke URL
    Best Answer

    Posted Mon January 09, 2023 03:34 PM

    Hi Michael,

    If your API is invoked with /users/steve for example, request.parameters.user would have a value of steve.   A shorthand for request.parameters.user  is {user} so in your invoke policy

    $(host-url)/users/{user}

    or 

    $(host-url)/users/$(request.parameters.user)

    would have a target url of something like https://hostname:port/users/steve
    Best Regards,
    Steve



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



  • 3.  RE: Get the value of path parameter and pass it to invoke URL

    Posted Wed January 11, 2023 02:02 AM

    Hello Steve,

    Good day! Thank you for explaining it perfectly and pointing me in the right direction. API endpoint works as expected now :) Cheers!



    ------------------------------
    Best regards,
    Michael Emil Rivera
    ------------------------------