Azure / api-management-policy-snippets

Re-usable examples of Azure API Management policies
MIT License
326 stars 147 forks source link

How to use set-body template="liquid" to access request body json attribute? #111

Open akhileshnirapure opened 10 months ago

akhileshnirapure commented 10 months ago

Hi,

The official documentation mentions that set-body can access request body here https://learn.microsoft.com/en-us/azure/api-management/set-body-policy#using-liquid-templates-with-set-body

"The set-body policy can be configured to use the Liquid templating language to transform the body of a request or response. This can be effective if you need to completely reshape the format of your message."

I would like to use set-body to access the request body json and extract specific property, so that It can be use to craft request body for another request.

How to achieve this?

I tried accessing by "body.argument." doesn't work.

fabiohaifa commented 9 months ago

I don't know if helps but I recentlly wrote about APIM transformation policy here: https://aka.ms/explore-apim-transformation-xml-to-json