Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Azure API管理中为查询字符串参数指定重写url_Azure_Azure Api Management - Fatal编程技术网

如何在Azure API管理中为查询字符串参数指定重写url

如何在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

我正在使用Azure API管理将传入的查询字符串转换为另一个查询字符串

我的转换代码是:

<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