[英]Azure API Management - Liquid Transformation does no longer work
I have several operations in Azure API Management which uses the liquid template.我在使用液体模板的 Azure API Management 中有几个操作。 A few weeks ago I recognized that existing liquid templates stopped working.
几周前,我意识到现有的液体模板停止工作。
Did I something wrong?我有什么问题吗? Is there an issue with API Management?
API 管理是否存在问题?
Based on the documentation I'm not able to find any errors.根据文档,我找不到任何错误。
Therefore I created a basic example that does not transform the request body.因此,我创建了一个不转换请求正文的基本示例。
Policy:政策:
<policies>
<inbound>
<base />
<return-response>
<set-status code="200" reason="OK" />
<set-body template="liquid">
{
"email":"{{body.EmailAddress}}"
}
</set-body>
</return-response>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Request:要求:
POST https://hidden.azure-api.net/evaluation/mm/liquid HTTP/1.1
Host: hidden.azure-api.net
Ocp-Apim-Subscription-Key: ••••••••••••••••••••••••••••••••
{
"EmailAddress": "sample@lorem.ipsum"
}
Response:回复:
HTTP/1.1 200 OK
content-length: 79
date: Wed, 10 Feb 2021 07:50:53 GMT
vary: Origin
{
"email":""
}
My expectation is transformed body:我的期望是变形的身体:
{
"email":"sample@lorem.ipsum"
}
Have you tried adding the Content-Type: application/json
header to your request?您是否尝试将
Content-Type: application/json
header 添加到您的请求中? Liquid only works if the content type is set, else it couldn't know how to parse the document properly. Liquid 仅在设置了内容类型时才有效,否则它不知道如何正确解析文档。
Microsoft Support informed me that the set-body policy with liquid template is not supported in return-response policy. Microsoft 支持通知我,返回响应策略不支持带有流动模板的set-body策略。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.