我在使用liquid模板的Azure API Management中有几个操作。几个星期前,我发现现有的液体模板停止工作了。
我做错了什么吗?API管理有问题吗?
根据文档,我找不到任何错误。
因此,我创建了一个不转换请求体的基本示例。
政策:
<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>
请求:
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"
}
反应:
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"
}
您是否尝试将Content-Type: application/json
标头添加到您的请求中?Liquid只能在设置了内容类型的情况下工作,否则它不知道如何正确解析文档。
Microsoft Support通知我,在return-response策略中不支持liquid模板的set-body策略。