Newbie : Question on ServiceCall: using calloutResponse.content

Hello,

Newbie here, developing first proxy running into challenges in using response from ServiceCallout. Really appreciate any guidance you can provide here.

API1 : For example, Returns {"city":"London"} as response.

ServiceCallOut :

(a) is created to call API1,retrieve response (city value), proceed to get other information.

(b) "calloutResponse" is the response name of my serviceCallOut.

After serviceCallout is made to API1, trying extract city using extract variables policy using below snippet.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV_From_SC_MockTarget">
    <DisplayName>EV_From_SC_MockTarget</DisplayName>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="IP_city">
            <JSONPath>$.calloutResponse.content.city</JSONPath>
            <!--<JSONPath>$.calloutResponse.content</JSONPath> -->
        </Variable>
    </JSONPayload>
   <Source>calloutResponse</Source>
</ExtractVariables> 

Behavior : Looks like no values getting assigned to IP_city variable in subsequent parts of the proxy. Rather getting empty value , like listed below. "IP_city": "",


Questions : Is above right way to trying to extract response from serviceCallout ?. Please note that i referred https://docs.apigee.com/api-platform/reference/policies/service-callout-policy, unable to use calloutResponse.content as listed.

Thank you

Solved Solved
0 2 660
1 ACCEPTED SOLUTION

Turns out that , i just need to below snippet. Just "$.city" is good enough ($.calloutResponse.content.city is unnecessary)

Issue is resolved now, able to proceed ...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV_From_SC_MockTarget">
    <DisplayName>EV_From_SC_MockTarget</DisplayName>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="IP_city">
            <!--<JSONPath>$.calloutResponse.content.city</JSONPath> -->
            <JSONPath>$.city</JSONPath>
        </Variable>
    </JSONPayload>
    <Source>calloutResponse</Source>
</ExtractVariables>

View solution in original post

2 REPLIES 2

Turns out that , i just need to below snippet. Just "$.city" is good enough ($.calloutResponse.content.city is unnecessary)

Issue is resolved now, able to proceed ...

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EV_From_SC_MockTarget">
    <DisplayName>EV_From_SC_MockTarget</DisplayName>
    <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="IP_city">
            <!--<JSONPath>$.calloutResponse.content.city</JSONPath> -->
            <JSONPath>$.city</JSONPath>
        </Variable>
    </JSONPayload>
    <Source>calloutResponse</Source>
</ExtractVariables>

optimism
Participant V

Hi, @mjpurchase0531 

thanks for sharing the question & the solution.