Extract Variable : Trying to use dynamic Xpath for XML . Not able to deploy

Not applicable

Hi,

I am trying to extract url in extract variable policy from soap request . Below is xpath :

<XPath>//FaultRule/Fault[@name={request.queryparam.errName}]/code</XPath>

When I try to deploy the API , it throws below error .

Xpath is validated online. It returns url which am trying to extract.

Error Deploying

ExtractVariables ExtractVariablesErrorXML: Failed to compile xpath //FaultRule/Fault[@name={request.queryparam.errName}]/code. Context Revision:1;APIProxy:exceptionHandling;Organization:akshat24;Environment:test.

Trying on sample xml:

<FaultRule>
<Fault name="API_NoMatchFound">
<code>ERCD-06</code>
<error>Not Found</error>
<statusCode>404</statusCode>
<reason>Not Found</reason>
</Fault><Fault name="BCKEND_404">
<code>ERCD-01</code>
<error>invalid_data_error_occurred</error>
<statusCode>500</statusCode>
<reason>Bad Request</reason>
</Fault>
</FaultRule>

If we use following xpath:

<XPath>//FaultRule/Fault[@name='API_NoMatchFound']/code</XPath>

It works and allow to deploy the code.

Can we use xpath with dynamic values in extract variable policy.

Thanks,

Akshat Bhargava

0 2 511
2 REPLIES 2

@Anil Sagar - Can you please help here.

Thanks,

Santosh

@Akshat Bhargava , @santosh_ghalsasi ,

I don't think dynamic xpath with flow variables reference is supported as of today in Extract Variables Policy.

Your best bet is to convert to JSON & then use javascript to extract the needed information. You can also use Java Callouts with xml parsing capability to extract same.