我正面临着挑战,从json的身体打印价值在azure apim政策
{ "value": [ { "counterKey": "abc123", "periodKey": "0_86400", "periodStartTime": "2023-02-10T00:00:00Z", "periodEndTime": "2023-02-11T00:00:00Z", "value": { "callsCount": 4, "kbTransferred": 0.36328125 } } ], "count": 1, "nextLink": null}
我想打印“callsCount”:4、通过API政策
<send-request ignore-error="true" timeout="20" response-variable-name="apref" mode="new">
<set-url>myurl</set-url>
<set-method>GET</set-method>
<set-header name="Authorization" exists-action="override">
<value>@("Bearer " + (string)context.Variables["PSItoken"])</value>
</set-header>
</send-request>
<set-header name="NumberOfCounts" exists-action="override">
<value>@{
var jsonBody = ((IResponse)context.Variables["apref"]).Body.As<JObject>()["value"].ToString();
JArray jBody = JArray.Parse(jsonBody);
return String.Join("", jBody.Select(i => i.ToString()));
}</value>
</set-header>
<set-variable name="NumberOfCounts" value="@(context.Request.Headers.GetValueOrDefault("NumberOfCounts"))" />
我的保险单到底漏了什么?
1条答案
按热度按时间pprl5pva1#
每当打印API响应时,使用响应变量名并添加返回响应策略: