Constructing URL with query params in service callout

Not applicable

We're using Apigee to book appointments through a third-party API. I have a proxy endpoint (we'll call it "/appointment") that receives data: customer info (name, etc.), the appointment id, a reasonid, and a booking note. The first part is easy -- we send the customer info off to the external API and it returns a customer id. That works fine.

The next step is to call another target endpoint. The URL for that target takes the form <baseurl>/[appointmentid]?customer=[customerid]&reasonid=[reasonid]&bookingnote=[bookingnote]

The fields in square brackets, e.g., [appointmentid] are variables extracted from the initial request or, in the case of [customerid] from the response to the first target call.

In the PreFlow response for the initial request, I use an assign message to set the query parameters for the second proxy endpoint ("/schedule"), then have a service callout to that proxy endpoint.

I need the target url for the callout to reflect the format noted above, but if I put an ampersand in URL properties, I get an "invalid xml" message, and if I don't, the query parameters I'm setting in the assign message don't get into the outbound call.

Clearly, I'm missing something! Any help will be appreciated.

Solved Solved
1 4 5,641
1 ACCEPTED SOLUTION

@PPSNE

You can set the query parameters in the Service Callout policy itself. Please refer to "Define request line" tab under Samples section in the below link:

http://docs.apigee.com/api-services/reference/service-callout-policy

Regards,

Amar

View solution in original post

4 REPLIES 4

@PPSNE

You can set the query parameters in the Service Callout policy itself. Please refer to "Define request line" tab under Samples section in the below link:

http://docs.apigee.com/api-services/reference/service-callout-policy

Regards,

Amar

Hi Amar,

I followed the document and tried to add the queryparam in service callout policy but its not working for me. 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="EXT-SC-BearerTokenDetails">
<DisplayName>EXT-SC-BearerTokenDetails</DisplayName>
<Properties/>
<Request clearPayload="true" variable="myRequest">
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Set>
<Headers>
<Header name="Content-Type">application/x-www-form-urlencoded</Header>
</Headers>
<QueryParams>
<QueryParam name="client_id">{client_id}</QueryParam>
</QueryParams>
<FormParams>
<FormParam name="grant_type">client_credentials</FormParam>
<FormParam name="client_secret">{private.client_secret}</FormParam>
<FormParam name="scope">{scope}</FormParam>
</FormParams>
<Verb>POST</Verb>
</Set>
</Request>
<Response>tokenResponse</Response>
<HTTPTargetConnection>
<Properties>
<Property name="io.timeout.millis">3000</Property>
</Properties>
<URL>https://{AEPTokenEP}</URL>
</HTTPTargetConnection>
</ServiceCallout>

Thanks,

M Kumari.

Ask a new question, please. When you do, provide more details, like: have you insured that the client_id variable is set? 

Hi @dchiesa1,

Thanks for the quick response. Yes i have set the variable defined in kvm policy.

majjiku_0-1693417015364.png

 

Thanks,

M Kumari.