API Connect

 View Only
  • 1.  check header value and call respective backend

    Posted 15 days ago

    Hi,

    I've a usecase where i need to check the incoming request header (example: domain) once that header values matches then we need to call the respective backend endpoint. Can you please help on how we can implement this logic using switch condition in api connect v10 ?

    Example

    incoming request header name is domain

    if domain = a, then call a endpoint

    domain = b, then call b endpoint

    domain = c, then call c endpoint

    Appreciate your help on this.. Thank you



    ------------------------------
    Raja Kumar
    ------------------------------


  • 2.  RE: check header value and call respective backend

    Posted 7 days ago

    Hi Raja,
    In your switch policy conditions, assuming this is an API Gateway v2.0.0 switch policy, for each condition you can use request.headers.domain = 'x' where x is a | b | c.  Your rule for each conditional could be a separate invoke policy that hardcodes the backend target-url, or you could use a set variable in each rule that set some variable, call it endpoint-url, to the desired backend endpoint url, and then after the switch, you could have one invoke policy that simply uses that variable in the target-url property as $(endpoint-url).  Either way should work for you.

    Regards,
    Steve Linn



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