捕获传入的JSON [英] Capturing the Incomming JSON
问题描述
我只需要获取第3方API发布到我的APIM端点的传入JSON. Context.Request. ?请对此提出任何想法.是否有类似Context.Body的内容?
返回响应策略来构造复合响应.集合体元素 可以使用表达式构造一个新的JObject,并将所有组件表示形式都嵌入为属性.
<返回响应response-variable-name =现有响应变量"> < set-status code ="200"原因=确定" /> < set-header name ="Content-Type";存在动作=覆盖" < value> application/json</value> </set-header> < set-body> @(新JObject(新 JProperty("revenuedata",(((IResponse)context.Variables ["revenuedata"])).Body.As< JObject>()), ]新的 JProperty("materialdata",(((IResponse)context.Variables ["materialdata"]]).Body.As< JObject>()), ]新的 JProperty("throughputdata",(((IResponse)context.Variables ["throughputdata"]).Body.As< JObject>()), ]新的 JProperty("accidentdata",(((IResponse)context.Variables ["accidentdata"]]).Body.As< JObject>()) ).ToString()) </set-body> </return-response>
https://docs.microsoft.com/zh-CN/azure/api-management/api-management-sample-send-request#send-request .
如果此答案有帮助,请单击标记为答案"或投票.为了在您的论坛上提供其他反馈 体验,请单击 解决方案
You can use "send-request" policy, which enables using an external service to perform complex processing functions and return data to the API management service. You can construct the composite response, use the return-response policy. The set-body element can use an expression to construct a new JObject with all the component representations embedded as properties.
<return-response response-variable-name="existing response variable"> <set-status code="200" reason="OK" /> <set-header name="Content-Type" exists-action="override"> <value>application/json</value> </set-header> <set-body> @(new JObject(new JProperty("revenuedata",((IResponse)context.Variables["revenuedata"]).Body.As<JObject>()), new JProperty("materialdata",((IResponse)context.Variables["materialdata"]).Body.As<JObject>()), new JProperty("throughputdata",((IResponse)context.Variables["throughputdata"]).Body.As<JObject>()), new JProperty("accidentdata",((IResponse)context.Variables["accidentdata"]).Body.As<JObject>()) ).ToString()) </set-body> </return-response>
For more details, you may refer to this document: https://docs.microsoft.com/en-us/azure/api-management/api-management-sample-send-request#send-request.
------------------------------------------------------------------------------------------------------
If this answer was helpful, click "Mark as Answer" or Up-Vote. To provide additional feedback on your forum experience, click here
这篇关于捕获传入的JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!