0

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.

Alex
  • 3
  • 4

1 Answers1

1

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.

Pim H
  • 223
  • 2
  • 8
  • Does not work if the payload is plain text. The only solution that seems to work is by creating a JS or Python policy and processing it there. Something like `var response = context.getVariable("response.content"); //Parse the response context.setVariable("my_var", value);` – Eddoasso Feb 24 '22 at 16:01