I have a policy on all my operations in Azure API Management to validate a JWT Token and extract the
sub Claim, which I store in a
userId variable that can be used in other policies.
I have an operation called
Organization Add that calls an Azure Function to add an organization to the database.
The Azure Function expects a value for
userId in the body.
My policy for the
Organization Add operation needs to add the
userId to the body.
To do this I convert the incoming message body to a
JObject and then add the property and assign it the value of the
I tried, unsuccessfully, to use the variable inline using Liquid templates.
Took some time, but finally figured out how to do it thanks to this question posted on the Microsoft forums https://social.msdn.microsoft.com/Forums/en-US/3bb42ca6-adc4-4c70-ae31-a54b9d75ea10/sending-json-inside-policy-definition.
Hope this saves a fellow developer some time!