AnsweredAssumed Answered

Escaping spaces when calling the RESTful API

Question asked by Bret Truchan on Jun 24, 2016
Latest reply on Jun 30, 2016 by Francesca Shiekh

Hello!  I'm writing a node.js script which calls the v10 Sugar API.  Here's a tiny piece of the code:

  var api_url = baseurl+"/Accounts?filter[0][name]=" + name + "&fields=name,account,description,email";

 

This only works when the variable "name" has no spaces.  For example, "microsoft" or "apple".  When the name contains a space, like Acme LLC, it fails to return any results.  I've tried this:

  var api_url = baseurl+"/Accounts?filter[0][name]=" + encodeURIComponent(name) + "&fields=name,account,description,email";

 

But still no luck.  Any suggestions?

 

Thanks,

Bret

Outcomes