Hi,
I just upgraded my developer copy for a new client solution from 8.3.x to 8.4 and you seem to have changed some functionality in the http plugin that I can't see documented.
I am using it to access the UK Companies House API, that just required Basic authentication (in this case just passing my API key as username with a blank password
This was working with the following code
- Code: Select all
var client = plugins.http.createNewHttpClient();
var request = client.createGetRequest('https://api.companieshouse.gov.uk/search/companies?q=' + ch_number );
request.usePreemptiveAuthentication(true);
var response = request.executeRequest(myapiusername, '');
var httpCode = response.getStatusCode();
var content = response.getResponseBody();
but after the upgrade, this generated an error
Invalid authorization header
so after investigating, I managed to change the code to (with the svyUtils module)
- Code: Select all
var client = plugins.http.createNewHttpClient();
var request = client.createGetRequest('https://api.companieshouse.gov.uk/search/companies?q=' + ch_number );
request.usePreemptiveAuthentication(true);
var auth = scopes.svyCrypto.base64EncodeAsString(scopes.svyCrypto.string2Bytes(myapiusername + ':'));
request.addHeader('Authorization','Basic ' + auth);
var response = request.executeRequest();
var httpCode = response.getStatusCode();
var content = response.getResponseBody();
and now it works.
So it looks like you have changed something in the 'executeRequest' code to stop the old way of passing username/password from working [as my setup to test this in Postman did not change & still works].
If you have changed something like this, please document it somewhere.
[I hope this might help some other developer who hits this problem]
There are other things that seem to have changed that I will post separately.
[And PLEASE fix the forum login problems ASAP]
Rafi