Shawn Clark
Shawn Clark

Reputation: 41

Azure API Management policy search-and-replace

I'm working with Azure API Management policies and I'm trying to figure out how to remove namespace prefixes from the output of my SOAP pass-thru service.

The only solution I can find is to use this

<find-and-replace from="what to replace" to="replacement" />

Will find-and-replace accept a regular expression instead of a static string? Something like this?

<find-and-replace from="/(?!xmlns)^.*:/" to="" />

Upvotes: 1

Views: 4140

Answers (1)

Vitaliy Kurokhtin
Vitaliy Kurokhtin

Reputation: 7840

Unfortunately not, the idea behind find and replace policy is to replace without buffering whole message body, supporting regular expressions will require to buffer. But you can use policy expressions to achieve your task:

<set-body>@(Regex.Replace(context.Response.Body.As<string>(), "pattern", ""))</set-body>

Upvotes: 5

Related Questions