Company search / company name syntax

I’m new to both google apps script and the CH API. I want to query the api using a company name, so far i have the following code which is from this post Authentication Issue using Google App Script - #5 by emanuel_cohal :

function findCHInfo() {

//this works for a number

  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Sheet1")
  var optionsheet = ss.getSheetByName('Options');
  var sheet = ss.getSheetByName("Sheet1");

var my_api_key = optionsheet.getRange('C2').getValue();

// Logger.log(my_api_key);

var headers = {

"Authorization": "Basic " + Utilities.base64Encode(my_api_key+":"),


var params = {
"q":"Barclays Bank",
muteHttpExceptions: true,

//var url = "";
var url = ""

var response = JSON.parse(UrlFetchApp.fetch(url, params).getContentText());
Logger.log(params, response);


please could you advise on how to modify this code so i get a meaningful response? If i search using a number (as in the original code), then all the correct data comes back in the response, using a text string i get the following in the reponse:

[20-07-30 12:08:30:717 BST] {method=GET, q=Barclays Bank, muteHttpExceptions=true, headers={Authorization=Basic M0EydjNmZnpxc2JXSWJBa0dtR2FpcUdIdmEyYjVja3hGb19KTFJpRTo=}} {items=[], total_results=0.0, items_per_page=20.0, kind=search#companies, start_index=0.0, page_number=1.0}

Many thanks for any guidance!

ok, so forgive my ignorance, using the following:

var url = ""

i get a correct response…

so, do i first use replace() to remove spaces and replace with a + on my list of company strings or is there something else i’m missing?