我目前正在Azure API管理中使用policys,而我在提取從response-body返回的值時感興趣。如何從API管理策略中的響應主體中獲取價值?
<send-one-way-request mode="new">
<set-url>http://requestb.in/xje199xj</set-url>
<set-method>POST</set-method>
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
//JObject or string?
string response = context.Response.Body.As<string>(preserveContent: true);
//something here..
}
</set-body>
</send-one-way-request>
的迴應是這樣的:
"getBookableResourcesResponse": { "getBookableResourcesResult": { "hasError": false, "errorCode": 0, "BookableResource": [ { "resourceCode": "TRA", "description": "Trailer", "group": "F", "subGroup": "C", "category": "R", "dialogType": "CARGO", "orgCode": "DECK", "length": 14, "taraWeight": "7000", "grossWeight": "25001", "AddResource": [ { "resourceCode": "EXPFIN", "description": "Export Finland", "dialogType": "UNDEFINED", "amount": "0", "ticketType": "", "orgCode": "EXPFIN", "required": "false" }.....
我想從「resourceCode」屬性返回的值這就是,在這種情況下,「TRA」,然後創建一個新的JObject至於我可以發送給我的Azure功能。
{ 「resourceCode」: 「valueFromResponseBody」 }