Thank you for taking your time in helping me…I’ve deleted the initial API key and generated a new one…it is working now.
Updated script, in case anyone else needs this:
function myFunction() {
var id = “SheetId”;
var ss = SpreadsheetApp.openById(id);
var sheet = ss.getSheetByName(“Sheet1”);
var my_api_key = sheet.getRange(1,2,1,1).getValue();
Logger.log(my_api_key);
var headers = {
“Authorization”: “Basic " + Utilities.base64Encode(my_api_key+”:"),
}
var params = {
“method”:“GET”,
“headers”:headers,
muteHttpExceptions: true,
};
var url = “https://api.companieshouse.gov.uk/company/00000006”;
var response = JSON.parse(UrlFetchApp.fetch(url, params).getContentText());
Logger.log(response);
}