我正在利用 Azure API 管理解决方案编写概念验证。
我正在尝试编写一项<inbound>
执行以下操作的策略:
<send-request>
向 API 的身份验证端点发出请求。JObject
这就是我目前的政策:
<inbound>
<base />
<!-- Authenticate with the API and get authentication tokens for subsequent calls -->
<send-request mode="new" response-variable-name="auth" timeout="20" ignore-error="true">
<set-url>https://www.service.com/api/authenticate</set-url>
<set-method>POST</set-method>
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>
@{
var credentials = new JObject();
credentials.Add(new JProperty("logonId", "{{API_LOGON_USERNAME}}"));
credentials.Add(new JProperty("logonPassword", "{{API_LOGON_PASSWORD}}"));
return credentials.ToString();
}
</set-body>
</send-request>
<!-- Make …
Run Code Online (Sandbox Code Playgroud)