how to collect text data from response apigee

1.2k Views Asked by At

I am using serviceCalloutPolicy to get response from some "xyz" api. The response returned by "xyz" api is text data like "abnfhjdkdhrju784hhkfjhbbhg21g3u2u9fdjkfnfddsnrijirry3784yewrgshbsdjbcjsvnvksdnv" which is neither json nor xml . so how can extract this data into variable. I want to use this data as header in another api call.

1

There are 1 best solutions below

1
On BEST ANSWER

You can get the response value by using Extract Variable Policy.

Place it after your Service Callout Policy.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="EVTIB-ExtractValueFromJC">
    <DisplayName>EVTIB-ExtractValueFromJC"</DisplayName>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <Source clearPayload="false">yourJavaCalloutReponseName</Source>
    <VariablePrefix>resp.data</VariablePrefix>
    <JSONPayload>
        <!--- Extract value from Json or XML , for example Json-->
        <Variable name="apiRespData">
            <JSONPath>$.data</JSONPath>
        </Variable>
    </JSONPayload>
</ExtractVariables>

And then use variable name to reference the value.