Service callout response not being assigned to variable

Not applicable

I am performing a ServiceCallout that executes successfully, the response is JSON and I can see the response in the Service Callout Response under "Body" as well as the ServiceCallout.response property. However I am assigning the response to a variable but that is not being set.

Under variables I see "baas.request" which is assigned in an earlier AssignMessage, that works fine, but I don't see "baas.response" anywhere. Here is my service callout:

<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-BaaS">
    <DisplayName>Service Callout BaaS</DisplayName>
    <Properties/>
    <Request clearPayload="false" variable="baas.request"/>
    <Response>baas.response</Response>
    <HTTPTargetConnection>
        <Properties/>... more stuff...

As you can see the Response should be assigned to "baas.response". This is not set, I can't see it anywhere in the trace steps. In addition, what is strange is that I am using this variable in an ExtractVariables policy with continueOnError set to "false" and i'm not getting an error, nor am I getting any values, nor am I seeing the variables populated.

<ExtractVariables async="false" continueOnError="false" enabled="true" name="Process-BaaS-response">
    <DisplayName>Process BaaS response</DisplayName>
    <Properties/>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <JSONPayload>
        <Variable name="broker_name" type="string">
            <JSONPath>$.entities[0].name</JSONPath>
        </Variable>
    </JSONPayload>
    <Source clearPayload="false">baas.response</Source>

In the above you can see the Source is set as "baas.response". If I change it to something else like "xyz" that does not exist I get an error saying "xyz does not exist" so it looks like the variable is somehow detected but it does not appear in trace nor does it work.

Ideas?

Solved Solved
0 4 2,198
1 ACCEPTED SOLUTION

nmallesh
Participant V

Hi @Kevin A,

The response value will be stored in the variable baas.response and can be accessed by querying for

baas.response.content

Refer to the following variable definition -

calloutResponse.content

where calloutResponse is the <Response> variable name in the Service Callout configuration.
Scope : From Service Callout request forward

Type: String

Permission: Read/Write

The response body from the Service Callout.

Read more - Service Callout Policy

You can set this to false if you want the service callout policy to throw an error when the referenced variable is unresolvable.

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

Set to true to treat any unresolvable variable as an empty string (null). Set to false if you want the policy to throw an error when any referenced variable is unresolvable.

Read more - IgnoreUnresolvedVariables element

Keep us posted, Thanks

View solution in original post

4 REPLIES 4

nmallesh
Participant V

Hi @Kevin A,

The response value will be stored in the variable baas.response and can be accessed by querying for

baas.response.content

Refer to the following variable definition -

calloutResponse.content

where calloutResponse is the <Response> variable name in the Service Callout configuration.
Scope : From Service Callout request forward

Type: String

Permission: Read/Write

The response body from the Service Callout.

Read more - Service Callout Policy

You can set this to false if you want the service callout policy to throw an error when the referenced variable is unresolvable.

<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>

Set to true to treat any unresolvable variable as an empty string (null). Set to false if you want the policy to throw an error when any referenced variable is unresolvable.

Read more - IgnoreUnresolvedVariables element

Keep us posted, Thanks

Thanks Nisha, that worked. I was able to access the content and use ExtractVariables to get the data out and assign them to variables. I had to use the prefix "apigee." when using the variables.. I had not noticed the <VariablePrefix> tag.

Thanks a lot for your help!

And you need to use .content on the variable name when you refer to in the resources.

thanks @Nisha Mallesh...your answer on accessing the response content helped me big time :)...i'm kinda newbie with Apigee being from a C/Unix background...thanks again