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
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)
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]
i think that whole plugin got updated to the latest apache http client code
The thing is that usePreemtiveAuthentication should just exactly do that what you are now also doing by hand (setting that “authorization”) header
jcompagner:
i think that whole plugin got updated to the latest apache http client code
The thing is that usePreemtiveAuthentication should just exactly do that what you are now also doing by hand (setting that “authorization”) header
It didn’t seem to…
jcompagner:
can you make a case so we can have a look?
I will try to soon.
[and when will forum issues be sorted??]
Thanks
Rafi
ah those where directly using log4j api?
Servoy itself on te most places doesn’t do that we all go through the SLF4J api and log4j is just a backend for that…
rafig:
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
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)
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
I’ve updated my development environment from 8.1.4 → 8.4 successfully. I am now attempting to upgrade one of our linux (centOS) servers from 8.1.4 → 8.4 unsuccessfully. I get the error below when I run servoy_updater.jar with or without the releaserNumber option. I’ve found other posts reporting similar problems and tried the recommended versions of the servoy_updater.jar file without success.
Here is the error:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://download.servoy.com/downloads/0xx_updates/version_info.txt
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.URL.openStream(URL.java:1045)
at com.servoy.updater.VersionCheck.loadVersionInfoFile(VersionCheck.java:163)
For the next release we will ship it right into the developer and the developer will also update that file…
Thanks Johan
I’ve tried replacing the servoy_updater.jar file with the one posted in that discussion but it’s still failing for me.
Here’s the output:
Could not read current Servoy version: null
java.lang.NullPointerException
at com.servoy.updater.J2DBJarVersionReader.<init>(J2DBJarVersionReader.java:45)
at com.servoy.updater.VersionCheck.main(VersionCheck.java:354)
Current Servoy version 0
Checking for new Servoy version
Loading version info...
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://download.servoy.com/downloads/0xx_updates/version_info.txt
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.URL.openStream(URL.java:1045)
at com.servoy.updater.VersionCheck.loadVersionInfoFile(VersionCheck.java:163)
at com.servoy.updater.VersionCheck.main(VersionCheck.java:372)
so the problem is the first null pointer, that tried to load the file j2db.jar from the application_server\lib dir
then it wants to read in the manifest.mf file (in META-INF)
somehow that seems to be corrupted
So it could be that this will only work with a clean install