# Company search / company name syntax

**URL:** <http://forum.companieshouse.gov.uk/t/company-search-company-name-syntax/3204>\
**Category:** API Issues\
**Created:** [July 30, 2020, 11:12am UTC](http://forum.companieshouse.gov.uk/t/company-search-company-name-syntax/3204 "2020-07-30T11:12:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark101](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@mark101](http://forum.companieshouse.gov.uk/u/mark101)\
**Post date:** [July 30, 2020, 11:12am UTC](http://forum.companieshouse.gov.uk/t/company-search-company-name-syntax/3204/1 "2020-07-30T11:12:44Z")

</div>

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 [https://forum.aws.chdev.org/t/authentication-issue-using-google-app-script/2813/5](https://forum.aws.chdev.org/t/authentication-issue-using-google-app-script/2813/5) :

```
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 = {
"method":"GET",
"q":"Barclays Bank",
//items_per_page
"headers":headers,
muteHttpExceptions: true,
};

//var url = "https://api.companieshouse.gov.uk/company/00000006";
var url = "https://api.companieshouse.gov.uk/search/companies"

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!

---

<div class="post-metadata">

**Author:** ![mark101](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@mark101](http://forum.companieshouse.gov.uk/u/mark101)\
**Post date:** [July 30, 2020, 3:14pm UTC](http://forum.companieshouse.gov.uk/t/company-search-company-name-syntax/3204/2 "2020-07-30T15:14:33Z")

</div>

ok, so forgive my ignorance, using the following:

```
var url = "https://api.companieshouse.gov.uk/search/companies?q=barclays+bank"

```

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?
