Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Invalid JSON path error in Extract Variable

Below is my EV policy code

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="EV-UserHREF">
<DisplayName>EV-UserHREF</DisplayName>
<Properties/>
<JSONPayload>
<Variable name="user_href">
<JSONPath>$.id</JSONPath>
</Variable>
</JSONPayload>
<Source>response</Source>
</ExtractVariables>

Below is the error I get. 

{
"fault": {
"faultstring": "Invalid JSON path $.id in policy EV-UserHREF.",
"detail": {
"errorcode": "steps.extractvariables.InvalidJSONPath"
}
}
}

I have passed Content-Type as application/json  while calling proxy from POSTMAN.

EV policy is in target endpoint preflow response.

I have also test json xpath in xpath finder and it gives me correct path but it is not working in EV.

Please suggest.

Solved Solved
0 4 1,788
1 ACCEPTED SOLUTION

Below polices has worked for me

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-ContentType">
    <DisplayName>AM-ContentType</DisplayName>
    <Properties/>
    <Add>
        <Headers>
            <Header name="Content-Type">application/json</Header>
        </Headers>
    </Add>
    <AssignTo createNew="false" transport="http" type="response">varcomment</AssignTo>
</AssignMessage>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables continueOnError="false" enabled="true" name="EV-UserHREF">
    <DisplayName>EV-UserHREF</DisplayName>
    <Properties/>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <VariablePrefix>userurl</VariablePrefix>
    <JSONPayload>
        <Variable name="userhref">
            <JSONPath>$.[0]._links.self.href</JSONPath>
        </Variable>
    </JSONPayload>
    <Source>response</Source>
</ExtractVariables>

View solution in original post

4 REPLIES 4