Sidebar

How can I add query string parameters to a REST WS call?

0 votes
34 views
asked Apr 30 by rich-c-2789 (17,430 points)
edited Apr 30 by rich-c-2789
I need to add the following to the URL for WS call:

givenName, lastName, dob, gender,

How can I add them to the query string of the URL when the call is made?

For example:

http://host/location?givenName=myFirstName&lastName=myLastName&dob=19700101&gender=U

1 Answer

0 votes

The items are added to the query string with a parmater map. You put the key/value pairs in the parameter map and pass the parameter map to the qie.callRESTWwebService() as the "parameters" argument:

//Create a paramter map
var parameterMap = qie.newParameterMap();

//Add the key, value pairs to the parameter map
parameterMap.put("givenName", "myFirstName");
parameterMap.put("lastName", "myLastName");
parameterMap.put("dob", "19700101");
parameterMap.put("gender", "U");

//Pass the parameterMap into the callRESTWebService as the "parameters" argument.
var value = qie.callRESTWebService(
"My Webservice Connection",
null,
"GET",
null,
parameterMap,
60000);

 

See also:

Handling HTTP requests and responses

Making Requests via qie.callRESTWebService()

answered Apr 30 by rich-c-2789 (17,430 points)
edited 1 day ago by rich-c-2789
commented 9 hours ago by rich-c-2789 (17,430 points)
If you need to pass repeating parameters, use the urlTemplate parameter to construct a URL with the repeating query parameter. Use either the parameterMap or the urlTemplate but not both for the query string parameters.  Note: the parameterMap can still be used to set headers or be set to null.

Example:

var urlTemplate = qie.evaluateTemplate(
    qie.getWsEndpointUrl('My Webservice Connection') +
    "?givenName= myFirstName" +
    "&lastName=myLastName" +
    "&dob=19700101" +
    "&gender=U" +
    "&specialty=Nephrology" +
    "&specialty=Neurology" +
    "&specialty=Psychiatry"
);
...