1

Is there a way to pass the query param coming via the APIM request as path param to the backend service call? For example:

For the below API call

base_url/a/{pathParam1}?query=Qvalue

I want to transform the URL to:

base_url/a/Qvalue/{pathparam1}

Also I will be using the URL re-write policy to change the base_url and add newer query params.

Sanjay
  • 43
  • 8

1 Answers1

2

You can read the query parameter in policy expression with : context.Request.Url.Query.GetValueOrDefault("", "default value").

Asper the requirement, you need to change the uri, which can be set with rewrite-uri policy. So, your required policy statement should look like below (add in inbound section):

<rewrite-uri id="setQvalue" template="@{ 
                return "/base_url/a/Qvalue/"+context.Request.Url.Query.GetValueOrDefault("pathparam1", ""); 
            }" /> 
Pankaj More
  • 433
  • 3
  • 10