Comma encoding in request parameters

Not Yet Reviewed

I have a script in Flow Designer that is looking for active events with certain properties. It worked fine when I was looking for only one property, but now I want to look for two: "service" and "resource". 

The properties are supposed to be separated with commas. I have some code that assembles the GET request like so:

var prop_name = 'propertyName=' + encodeURIComponent('service#en') + ',' + encodeURIComponent('resource#en');
var prop_value = 'propertyValue=' + encodeURIComponent(input['service']) + ',' + encodeURIComponent(input['resource']);
var prop_operator = 'propertyValueOperator=CONTAINS'; 
var _limit = 'offset=0&limit=500';
var _status = 'status=ACTIVE';

var apiRequest = http.request({
'endpoint': 'xMatters',
'path': '/api/xm/1/events?' + _status + '&' + prop_name + '&' + prop_value + '&' + prop_operator + '&' + _limit,
'method': 'GET'

The GET request returns 200 OK status but doesn't come up with the events I'm expecting to find. I think it's because the commas are being encoded to %2C: 


Would the comma encoding cause this request to fail? Is there a way I can get around it?



Date Votes

Please sign in to leave a comment.

  • Hi Michael,

    I've seen this happen once before and suspect you may be running into something similar.

    According to our documentation here:

    you can force the URL encoding behavior and account for that comma by making it NOT auto-encode. This is the relevant bit:


    HTTP request object and write function

    The following function returns an HTTP request object that can later be sent using its write() function:


    The request function accepts a JavaScript object representing its options. The following table describes the available options:

    Option Type Required Purpose
    endpoint string yes

    Name of the pre-configured endpoint (case-sensitive) that the request is targeting.

    NoteSlack endpoints require an additional function call to add the Slack token to API requests.

    method string   HTTP request method to use; default is GET
    path string   Path to append to the URL defined in the pre-configured endpoint. Querystring parameters may be included.
    headers object   HTTP headers to send with the request.
    autoEncodeURI boolean/string  

    By default, the Integration Builder automatically encodes some characters in the URI (for example, spaces and slashes). This helps us standardize the URLs and create default configurations for our built-in and packaged integrations that have the best chance of succeeding wherever they find themselves.

    However, we recommend that you override this default behavior and manually encode special characters. That way, you can make sure you're sending exactly the request you intend — and not leaving it up to a machine to interpret.

    To override this behavior, include the autoEncodeURIproperty and set it to false.


    In short, if you are using http.request() then change this:
    var request = http.request({
    "endpoint": "xMatters",
    "method": "GET",
    "path": eventsURL


    var request=http.request({
    "endpoint": "xMatters",
    "autoEncodeURI": "false",
    "method": "GET",
    "path": eventsURL

    and it should work fine.


  • Thanks Francois, that solved my problem. I added:


    to the definition of the request variable. 


Didn't find what you were looking for?

New post