Hi
I’ve written a deluge script to pull accounts from CH but I keep getting a response with no filing history even though there is. Any ideas?
The response; { filing_history_status: ‘filing-history-available’ , items: array(0) , items_per_page: 25 , start_index: 0 , total_count: 0 }
Below is the code
void automation.CompaniesHouseAccountsPDF1()
{
company_numbers = list();
company_numbers.add(“1234”);
company_numbers.add(“45678”);
company_numbers.add(“9101112”);
company_numbers.add(“1179939”);
companies_house_api_key = “XXX”;
workdrive_folder_id = “XXX”;
pdf_files = list();
for each company_number in company_numbers
{
url = “https://api.company-information.service.gov.uk/company/” + company_number + “/filing-history”;
headers = Map();
encoded_key = zoho.encryption.base64Encode(companies_house_api_key + “:”);
headers.put(“Authorization”,"Basic " + encoded_key);
response = invokeurl
[
url :url
type :GET
headers:headers
];
info response;
info response.get(“category”);
info response.get(“items”);
if(response != null && response.contains(“items”))
{
for each item in response.get(“items”)
{
if(item.contains(“category”) && item.get(“category”) == “accounts”)
{
document_url = “https://find-and-update.company-information.service.gov.uk/company/” + company_number + “/filing-history/” + item.get(“transaction_id”) + “/document”;
if(item.contains(“description_values”) && item.get(“description_values”).contains(company_number))
{
desc = item.get(“description_values”);
}
file_name = company_number + “.pdf”;
file_content = invokeurl
[
url :document_url
type :GET
headers:headers
];
info file_content;
header = Map();
header.put(“Accept”,“application/vnd.api+json”);
list_of_text = List();
list_of_text.add({“paramName”:“filename”,“content”:file_name,“stringPart”:“true”});
list_of_text.add({“paramName”:“parent_id”,“content”:workdrive_folder_id,“stringPart”:“true”});
list_of_text.add({“paramName”:“override-name-exist”,“content”:“true”,“stringPart”:“true”});
list_of_text.add({“paramName”:“content”,“content”:file_content,“stringPart”:“false”});
response = invokeurl
[
url :“https://www.zohoapis.eu/workdrive/api/v1/upload”
type :POST
headers:header
files:list_of_text
connection:“workdrive”
];
info response;
if(response.contains(“data”))
{
uploaded_file_id = response.get(“data”).get(0).get(“id”);
pdf_files.add(uploaded_file_id);
}
if(item.get(“category”) == “accounts”)
{
break;
}
}
}
}
}
}