简体   繁体   English

Azure API 管理 - 液体转换不再起作用

[英]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.

相关问题 Azure API 管理网关改造政策 - Azure API Management gateway transformation policy Azure API管理套装-带液体模板 - Azure API Management Set-Body with liquid template azure api 管理改造 URL Z099FB995346F31C749F6E40DB0F39 使用E网关 - azure api management transformation URL header using Application gateway 液体模板转换在 Azure 逻辑应用程序中不起作用 - Liquid template transformation is not working in Azure Logic app Azure API管理服务发布者门户不再显示“分析”选项卡 - Azure API Management service publisher portal no longer showing Analytics tab 如何使用Azure API-Management set-body中的液体模板解析查询字符串? - How can I parse a querystring using liquid template in Azure API-Management set-body? 在最近的 Azure API 管理升级后,为什么以前稳定且有效的 Liquid 模板会失败? - Why would a previously stable and working Liquid template fail after the most recent Azure API Management upgrade? Azure API管理是否包含WAF功能? - Does Azure API Management include WAF functionality? Azure API 管理缓存不起作用,并出现错误“请求不可缓存,策略未应用”。 - Azure API Management caching does not work with error "Request is not cacheable, policy was not applied." Azure API 管理支持流吗? - Does Azure API Management support streaming?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM