Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Assignmessage policy is not appending the query string parameters to the service callout url

Not applicable

My scenario is calling a service B with some parameters that are passed in the request query string. I have to introduce a service callout in the preflow to call service A with those parameters set in AssignMessagePolicy, get the response of A and extract the required fields using ExtractVariables policy and pass them to service B. I have done with what all required but the flow fails as service callout to service A is not having query string parameters in the url though they were set in ASsignMessagePolicy.

AssignMessagePolicy to service A:

<AssignMessage async="false" continueOnError="false" enabled="true" name="API-V1-Request"> <DisplayName>API V1 Request</DisplayName> <AssignTo createNew="true" type="request">InitializeAPIRequest</AssignTo> <Set> <QueryParams> <QueryParam name="apiKey">{request.queryparam.apiKey}</QueryParam> <QueryParam name="applicationId">{request.queryparam.applicationId}</QueryParam> <QueryParam name="twoDigitISOLanguageCode">{request.queryparam.twoDigitISOLanguageCode}</QueryParam> <QueryParam name="twoDigitISOCountryCode">{request.queryparam.twoDigitISOCountryCode}</QueryParam> </QueryParams> <Verb>GET</Verb> </Set> <!-- Set variables for use in the final response --> <AssignVariable> <Name>apiKey</Name> <Ref>request.queryparam.apiKey</Ref> </AssignVariable> <AssignVariable> <Name>applicationId</Name> <Ref>request.queryparam.applicationId</Ref> </AssignVariable> <AssignVariable> <Name>twoDigitISOLanguageCode</Name> <Ref>request.queryparam.twoDigitISOLanguageCode</Ref> </AssignVariable> <AssignVariable> <Name>twoDigitISOCountryCode</Name> <Ref>request.queryparam.twoDigitISOCountryCode</Ref> </AssignVariable> </AssignMessage>

ServiceCallout:

<ServiceCallout name="API-V1-InitializeAPI"> <Request variable="API-V1-Request"/> <Timeout>300000</Timeout> <Response>InitializeAPIResponse</Response> <HTTPTargetConnection> <URL>http://api.art.com/ECommerceAPI.svc/jsonp/InitializeAPI</URL> </HTTPTargetConnection> </ServiceCallout>

ExtractVariablesPolicy:

<ExtractVariables name="API-V1-Response"> <Source>InitializeAPIResponse</Source> <VariablePrefix>intializeresponse</VariablePrefix> <JSONPayload> <Variable name="CustomerZoneID"> <JSONPath>$.d.CustomerZoneID</JSONPath> </Variable> <Variable name="CurrencyCode"> <JSONPath>$.d.IsoCurrencyCode</JSONPath> </Variable> </JSONPayload> </ExtractVariables>

AssignMessagePolicyto service B:

<AssignMessage name="Products-V2-Request"> <Remove> <QueryParams> <QueryParam name="apiKey"/> <QueryParam name="applicationId"/> <QueryParam name="twoDigitISOCountryCode"/> <QueryParam name="twoDigitISOLanguageCode"/> </QueryParams> </Remove> <Set> <QueryParams> <QueryParam name="customerZoneId">{intializeresponse.CustomerZoneID}</QueryParam> </QueryParams> </Set> </AssignMessage>

Proxy Endpoints:

PreFlow:

<PreFlow name="PreFlow"> <Request> <Step> <Name>API-V1-Request</Name> </Step> <Step> <Name>API-V1-InitializeAPI</Name> </Step> <Step> <Name>API-V1-Response</Name> </Step> <Step> <Name>Products-V2-Request</Name> </Step> <Step> <Condition>request.verb equals "GET" and proxy.pathsuffix MatchesPath "/Products/*"</Condition> <Name>ValidateOAuth</Name> </Step> </Request> <Response/> </PreFlow>

Solved Solved
0 6 1,286
1 ACCEPTED SOLUTION

Not applicable

@Sagar Mummidivarapu

Your Service Callout should be using the value of the AssignTo from of the AssignMessage not the name of the policy.

You have: <Request variable="API-V1-Request"/>.

Should be: <Request variable="InitializeAPIRequest">

View solution in original post

6 REPLIES 6