Welcome! I don’t use either Zoho CRM or the Deluge script but:
-
The 400 response suggests there is an issue with the URL you’re sending. Other responses (according to the documentation for this endpoint) could be 404 (the URL made sense but data was not found), 401 (you weren’t authorised - normally an issue with the API key OR how you set up your “application” when you registered OR how you encoded the API key. (Also rate-limiting responses possible e.g. 429)
-
looking at the documentation Google found for the invokeurl task in Deluge also suggests that how you’re specifying the parameters for that may be the issue. I don’t know if that documentation is correct but there seem to be two possible issues:
- The “Parameters” part appears to be for returning e.g. Form data values (in one of a couple of encodings / formats). So per your code you would appear to be sending in a string of literal value:
https://api.company-information.service.gov.uk/company/Company_Number
… as well as a body with some form values (with the “13931909” as a key …)
What Companies House is expecting is the company number to appear in the URL after the “/company/
” part. You need to build that string yourself (there may be a function for this in Deluge of course). I would then remove the “Parameters” part completely - Companies House does not expect you to send a body in this API.
- Unless you’re not showing it in full I think your Authorization header may not be correct either. Companies House uses http basic Authorization - that requires the following string to appear in the headers:
Authorization: Basic
{B64_username:password}
…where the {B64_username:password} part is the http username plus the “:” character plus a password, all base-64 encoded. In this case, per Companies House documentation, the username is your API key, there is no password.
I don’t know how you’d do this in Deluge - you will need to check exactly how it generates the required header string. There appears to be a base-64 encoding function) if as suggested you need to do this yourself. (It is just possible that the system recognises this header and does this automatically but it doesn’t look like it). I’m guessing what you need is something like:
header_data = Map();
header_data.put(“Authorization”,“Basic
{My_encoded_API_KEY_plus:}”);
e.g. the “key” part in this map is likely to be just “Authorization” (or possibly “Authorization:” - depends how Deluge uses the keys to generate header strings). The “value” part is everything after the “:” - again depending on Deluge you may or may not need to provide a space at the start of this string! The brackets ("{" and “}”) and the part between them you would replace with the base64-encoded version of your API key plus the “:” character.
If not sure about this check out Companies House documentation (linked above, they have an example) and / or general documentation on http Basic and http headers.
Good luck.