question

CosminStirbu-1831 avatar image
0 Votes"
CosminStirbu-1831 asked PramodValavala-MSFT answered

Azure API Management minify JSON with liquid

Hello,

We're using API Management to wrap a SOAP (XML) based endpoint and expose JSON via a <set-body template="liquid"> policy.

Is there a way to minify the JSON in the body while keeping the policy readable?

Thank you,
Cosmin

azure-api-management
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT answered

@CosminStirbu-1831 You can use the set-body policies multiple times. So, after setting the body using liquid, you can add the following file to serialize it accordingly.

<set-body template="none">@(context.Response.Body.As<JObject>().ToString(Newtonsoft.Json.Formatting.None))</set-body>
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.