Skip to Content
May 24, 2016 at 02:36 PM

Extract Variable from ODATA API


Hello all,

I went through the very good guide from Holger in order to get started with HCP SAP APIM.

In order to create a custom dashboard, I would like to retrieve some information from the response of the SalesOrderSet resource, using an ExtractVariables policy, combined with a Statistics Collector Policy.

Here is the XML response I get for a specific SalesOrder:

<?xml version="1.0" encoding="utf-8"?>

<entry xml:base="https://SAPES4.SAPDEVCENTER.COM:443/sap/opu/odata/iwbep/GWSAMPLE_BASIC/" xmlns="" xmlns:m="" xmlns:d="">


<title type="text">SalesOrderSet('0500000000')</title>


<category term="/IWBEP/GWSAMPLE_BASIC.SalesOrder" scheme=""/>

<link href="SalesOrderSet('0500000000')" rel="self" title="SalesOrder"/>

<link href="SalesOrderSet('0500000000')/ToBusinessPartner" rel="" type="application/atom+xml;type=entry" title="ToBusinessPartner"/>

<link href="SalesOrderSet('0500000000')/ToLineItems" rel="" type="application/atom+xml;type=feed" title="ToLineItems"/>

<content type="application/xml">



To extract the SalesOrderID, I configured my ExtractVariables policy as follows:

<!-- Extract content from the request or response messages, including headers, URI paths, JSON/XML payloads, form parameters, and query parameters -->

<ExtractVariables async="false" continueOnError="false" enabled="true" xmlns=''>

<Source clearPayload="false">response</Source>


<XMLPayload stopPayloadProcessing="true">


<Namespace prefix="d"></Namespace>

<Namespace prefix="m"></Namespace>


<Variable name="SalesOrderID" type="string">





However, when saving and updating the proxy, I get the following error message:

[Request ID: c27460bb-74f4-427f-a8b7-637f3be0db38]

Policy content for policy "SalesOrderID" is invalid. cvc-complex-type.2.4.d: Invalid content was found starting with element 'Namespace'. No child element is expected at this point.

IMHO, my policy is in line with the documentation SAP API Management

My workaround is pretty easy (XML-to-JSON, and then using a JPath) but I would like to see this working natively.

Thanks for any help!