[英]Response change in azure apim set-body policy issue
I am using set-body to manipulate response my actual response is like below我正在使用 set-body 来操纵响应我的实际响应如下
{
"collection": {
"version": "1.0",
"href": "https://conferenceapi.azurewebsites.net:443/speakers",
"links": [],
"items": [
{
"href": "https://conferenceapi.azurewebsites.net/speaker/1",
"data": [
{
"name": "Name",
"value": "Scott Guthrie"
}
],
"links": [
{
"rel": "http://tavis.net/rels/sessions",
"href": "https://conferenceapi.azurewebsites.net/speaker/1/sessions"
}
]
}
]
}
}
and I want response like我想要这样的回应
{
"customer": {
"customerID": "1.0"
}
}
but i am getting response like但我得到的回应是
{
"customer": {
"customerID":
}
}
I have used below code in my outbound我在出站时使用了以下代码
<outbound>
<set-header name="Content-Type" exists-action="append">
<value>application/json</value>
</set-header>
<set-body template="liquid">{
"customer": {
"customerID": {{body.collection.version}}
}
}</set-body>
</outbound>
could u let me know where i am going wrong你能告诉我我哪里出错了吗
You have to do this in the inbound section.您必须在入站部分执行此操作。
The outbound section does contain the request-body.出站部分确实包含请求正文。
I was able to reproduce your issue: It was not working when the Content-Type of the request was missing.我能够重现您的问题:当请求的 Content-Type 丢失时它不起作用。 It was working with the request Content-Type application/json .
它正在处理请求 Content-Type application/json 。
BTW: For a valid JSON, quotes are required: "customerID": "{{body.collection.version}}"顺便说一句:对于有效的 JSON,需要引号:“customerID”:“{{body.collection.version}}”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.