Accessing Public Data

Hi I’m trying to access the Public Data API via Google Apps Script. Every time I run the code the following message appears: “error”:“Empty Authorization header”,“type”:“ch:service” I’m not sure where I’m going wrong, I’d appreciate it if anyone had any advice.

Here’s my code:

function run () {

var options = {

‘Authorization’: ‘Basic’,

‘ApiKey’: ‘46bd176e-b8ac-4fcc-xxxx-xxxxxxxxxx:’

};

var url = ‘https://api.company-information.service.gov.uk/company/11291018’;

var response = UrlFetchApp.fetch(url,options);

var result = JSON.parse(response.getContentText());

Logger.log(JSON.stringify(result, null, 2));

}

Welcome. There was a similar question just a couple of days ago. That should help you:

If you search this forum you’ll find just about every possible scenario for logging on to Companies House covered. There is not a “curated” index though - you’ll have to do the searching and understanding for yourself.

Good luck.

Hi @voracityemail thank you for your quick response! However I’m using Google Apps Script which runs via Google servers instead of locally. Do you have any other suggestions?

The forum has a search button (top right). Searching “Google Apps” there pops up:

Thanks so much for forwarding the link, my code is now working!!