I want to callout a service, extract the variables from that service's json and assign those variables to the response of this flow. The service callout's response contains the variables, but I am unable to extract them. What can I do to fix this?
Policies and final response below
service callout policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ServiceCallout async="false" continueOnError="false" enabled="true" name="refresh-external-callout"> <DisplayName>refresh external callout</DisplayName> <Properties/> <Request clearPayload="true" variable="myRequest"> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <Set> <QueryParams> <QueryParam name="grant_type">refresh_token</QueryParam> <QueryParam name="refresh_token">{oauthv2accesstoken.generate-external-token.refresh_token}</QueryParam> </QueryParams> <FormParams> <FormParam name="client_id">{request.formparam.client_id}</FormParam> <FormParam name="client_secret">{request.formparam.client_secret}</FormParam> </FormParams> <Verb>POST</Verb> </Set> </Request> <Response>calloutResponse</Response> <LocalTargetConnection> <Path>/am/oauth2/token</Path> </LocalTargetConnection> </ServiceCallout>
extract variables policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="extract-refresh-callout-response"> <DisplayName>extract refresh callout response</DisplayName> <Properties/> <JSONPayload> <Variable name="access_token"> <JSONPath>$.access_token</JSONPath> </Variable> <Variable name="refresh_token"> <JSONPath>$.refresh_token</JSONPath> </Variable> <Variable name="expires_in"> <JSONPath>$.expires_in</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">calloutResponse</Source> </ExtractVariables>
assign message policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="external-token-response"> <DisplayName>external token response</DisplayName> <Properties/> <Set> <Payload contentType="application/json" variablePrefix="@" variableSuffix="#"> { "access_token": "@access_token#", "expires_in": "@expires_in#", "refresh_token": "@refresh_token#" } </Payload> </Set> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="https" type="response"/> </AssignMessage>
response I get:
{ "access_token": "", "expires_in": "", "refresh_token": "" }