Azure API 管理:替换查询字符串参数名称

J B*_*min 1 url-rewriting azure-api-management

APIM 新手。尝试使用后端 api 期望的不同名称更改公开的查询字符串参数名称(而不是值)

例如,APIM 端点需要 /v1/Customer?CustomerId=123

我想我需要在入站部分使用 rewrite-url 策略?

要将其更改为:/v1/Customer?ExternalCustomerId=123


正在尝试这个,不起作用

<set-query-parameter name="ExternalCustomerId" exists-action="append">
        <value>@(Context.Request.QueryString["CustomerId"])</value>
    </set-query-parameter>
Run Code Online (Sandbox Code Playgroud)

错误:当前上下文中不存在名称“Context”

小智 6

自 2019 年 9 月起,这一情况已发生变化。现在使用以下内容:

<set-query-parameter name="ExternalCustomerId" exists-action="append">
    <value>@(context.Request.Url.Query.GetValueOrDefault("CustomerId"))</value>
</set-query-parameter>
Run Code Online (Sandbox Code Playgroud)