Azure API Management – Liquid Template – Escape XML Characters

Requirement:

Create an API that allows creation of customer in backend ERP.

API should be accessible publicly and secured.

Landscape:

  1. ERP is SAP and is located on a on-premise network.
  2. BizTalk is used as middleware to connect to SAP and is also located on-premise. BizTalk doesn’t have a public endpoint available.
  3. Azure API Management is deployed in Azure cloud without direct connection to on-premise network.

Solution:

  1. BizTalk to leverage WCF-BasicHttpRelay to Azure Service Bus to be able to have public endpoint.

2. Azure API management to convert the JSON Request to XML message using Liquid Template.

3. Azure API management to send the request to Azure Service Bus.

4. BizTalk receives the request in XML and send the request to SAP.

Problem:

If the JSON request contains XML reserved characters: & < > ‘ the request is failing in Azure API management.

Solution:

Add the following to the policy:

<!–Replace Reserved XML characters from Request Body–>