如何在Azure API管理中为查询字符串参数指定重写url
我正在使用Azure API管理将传入的查询字符串转换为另一个查询字符串 我的转换代码是:如何在Azure API管理中为查询字符串参数指定重写url,azure,azure-api-management,Azure,Azure Api Management,我正在使用Azure API管理将传入的查询字符串转换为另一个查询字符串 我的转换代码是: <policies> <inbound> <rewrite-uri template="api/primes?a={a}&b={b}" /> <base /> </inbound> <backend> <base /> </bac
<policies>
<inbound>
<rewrite-uri template="api/primes?a={a}&b={b}" />
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
它引用了a={a}
中的等于符号。如何更正重写uri的模板?例如,输入url是https://example.com/sum?a=7&b=5
尝试更换:
<rewrite-uri template="api/primes?a={a}&b={b}" />
与:
有关详细信息,请访问。您只需在APIM中创建“查询参数”,而无需创建“模板参数”。 然后,您的重写uri不需要包含查询参数,因为一旦通过inbound提供,APIM将自动将其添加到后端url
<rewrite-uri template="api/primes" />
然后发送到后端的HTTP请求如下所示:
https://example.com/sum?a=7&b=5
GET backendapi/api/primes?a=7&b=5
https://example.com/sum
GET backendapi/api/primes
如果请求URL没有如下查询字符串:
https://example.com/sum?a=7&b=5
GET backendapi/api/primes?a=7&b=5
https://example.com/sum
GET backendapi/api/primes
然后发送到后端的HTTP请求将如下所示:
https://example.com/sum?a=7&b=5
GET backendapi/api/primes?a=7&b=5
https://example.com/sum
GET backendapi/api/primes