如何从响应 apigee 收集文本数据

how to collect text data from response apigee

我正在使用 serviceCalloutPolicy 从某些 "xyz" api 获得响应。 "xyz" api 返回的响应是像 "abnfhjdkdhrju784hhkfjhbbhg21g3u2u9fdjkfnfddsnrijirry3784yewrgshbsdjbcjsvnvksdnv" 这样的文本数据,它既不是 json 也不是 xml 。那么如何将这些数据提取到变量中。我想在另一个 api 调用中将此数据用作 header。

您可以使用提取变量策略获取响应值。

将其放在您的服务标注政策之后。

<?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>

然后用变量名引用这个值