【发布时间】:2021-07-22 06:35:37
【问题描述】:
我在使用 APIM URL 重写策略时遇到问题,我需要使用变量的后缀值。我尝试了各种方法,但总是以错误结束“无法将'Microsoft.WindowsAzure.ApiManagement.Proxy.Gateway.PipelineResponse'类型的对象转换为'System.String” em>
这是我的入境政策:
<inbound>
<!-- Send Requst to Logic Apps to retrieve the corresponding suffix -->
<send-request mode="new" response-variable-name="Response_Suffix" timeout="20" ignore-error="true">
<set-url>{{LogicAppsURL}}</set-url>
<set-method>POST</set-method>
<set-header name="Content-Type" exists-action="append">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("ModelName", (context.Request.Body.As<JObject>(preserveContent: true).SelectToken("ModelName")))).ToString();
}</set-body>
</send-request>
<set-variable name="URL_Suffix" value="@((IResponse)context.Variables["Response_Suffix"])" />
<!-- Set Backend URL -->
<set-backend-service base-url="{{BaseURL}}" />
<base />
<!-- Rewrite URL -->
<rewrite-uri template="@((string)context.Variables["URL_Suffix"])" />
</inbound>
【问题讨论】:
标签: json azure casting url-rewriting azure-api-management