- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 09:55 AM
A particular outbound REST API that I am calling seems to care about the order of my parameters in the URL.
I've tried to control this in 2 different ways:
Method #1: Adding query parameters in my desired order through my script:
var incontactREST = new sn_ws.RESTMessageV2('inContact_API', 'get');
incontactREST.setStringParameter("authorization", token);
incontactREST.setStringParameter('url', 'services/v11.0/agents/' + agentNum + '/statehistory');
incontactREST.setStringParameter('contentType', 'application/x-www-form-urlencoded');
incontactREST.setQueryParameter("startDate", datestart);
incontactREST.setQueryParameter("endDate", dateend);
incontactREST.setQueryParameter("mediaTypeId", "0");
incontactREST.setQueryParameter("outboundStrategy", "0");
incontactREST.setQueryParameter("updatedSince", updatedSince);
However, this still results in the following URL:
services/v11.0/agents/2471149/statehistory?mediaTypeId=0&outboundStrategy=0&endDate=2018-02-14T00:00:00-0600&updatedSince=2018-02-13T11:19:33-0600&startDate=2018-02-13T00:00:00-0600
- I'm not quite sure how's sorting those parameters in the URL. They're definitely not alphabetical by label, nor alphabetical by value.
Method #2: Doing variable substitution, then setting the Order field on each query parameter.
var incontactREST = new sn_ws.RESTMessageV2('inContact_API', 'get');
incontactREST.setStringParameter("authorization", token);
incontactREST.setStringParameter('url', 'services/v11.0/agents/' + agentNum + '/statehistory');
incontactREST.setStringParameter('contentType', 'application/x-www-form-urlencoded');
incontactREST.setStringParameter('startDate', datestart);
incontactREST.setStringParameter('endDate', dateend);
incontactREST.setStringParameter('mediaTypeId', '0');
incontactREST.setStringParameter('outboundStrategy', '0');
incontactREST.setQueryParameter("updatedSince", updatedSince);
However, this also results in the same URL confusingly enough:
services/v11.0/agents/2471149/statehistory?mediaTypeId=0&outboundStrategy=0&endDate=2018-02-14T00:00:00-0600&updatedSince=2018-02-13T11:19:33-0600&startDate=2018-02-13T00:00:00-0600
Has anyone else run into this issue?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 10:56 AM
I've had problems with using Query Parameters, so your Method #3 option would be to just build your entire endpoint in the endpoint field and use the variables within it.
services/v11.0/agents/2471149/statehistory?outboundStrategy=${outboundStragety}&endDate=${endDate}&updatedSince=${updatedSince}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 10:56 AM
I've had problems with using Query Parameters, so your Method #3 option would be to just build your entire endpoint in the endpoint field and use the variables within it.
services/v11.0/agents/2471149/statehistory?outboundStrategy=${outboundStragety}&endDate=${endDate}&updatedSince=${updatedSince}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-13-2018 05:09 PM
Ah great idea! Through the following function:
incontactREST.setEndpont( desiredURL);