Plugin Http client Error 404

Hi
I think there is a problem with the http plugin
It is impossible to connect with any portal, in my case to read Prestahop portals

Whit Servoy vesrion 2022.6 works fine but with the 2022.9.2 dosen´t work

Always return error 404.

If I read the same url with Postman or with Servoy version 2022.6 and it’s works fine

Thanks

I’m using the plugin and it works for us without problems.

Can you post such a url and check if the “/” are correctly in place, that has changed, before 2022.09 you could use something like “https://forum.servoy.com//viewtopic.php?f=22&t=23677”, that has changed due to an update of the http-plugin.

Postman corrects “//” automatically, so you would not notice problems there.

And you should check that you always close the http-connection after use, that gave us some problems with memory.

2022.09 we updated the whole underlying HttpClient Engine to a newer version of Apache HC
that had some side effects that some stuff did work differently now.
in the latest release that is in 2022.12.RC3 (released shortly) the things that we know of should be fixed or work the same again.

but without knowing what sites you hit with what url we can’t see what is going on

We use http with diferents web services and since Servoy 2022.9.2, the connection with Prestashop portals dosen´t work

It’s work fine with woocommerce portals

jcompagner, send me and email for send the url of one of the our Prestashop portals

It is very urgent to solve this problem because we have several clients who have lost the connection with their Prestashop portals

Thanks

These are some result of probe with the Servoy version 22.6 and Servoy version 22.9.02 after response=getRequest.executeRequest() at the same Prestahop portal

With Servoy 22.6
response.getCharset() the result is “utf-8”
response.getResponseHeaders() the result is {Access-Time:[“1671815330”],Connection:[“keep-alive”],Content-Sha1:[“19207521eda9cef310e5eb0d73cf10b14cf91904”],Content-Type:[“text/xml;charset=utf-8”],Date:[“Fri, 23 Dec 2022 17:08:50 GMT”],Execution-Time:[“0.041”],Keep-Alive:[“timeout=15”],PSWS-Version:[“1.7.8.6”],Server:[“Apache”],Transfer-Encoding:[“chunked”],X-Powered-By:[“PrestaShop Webservice”]}

With Servoy 22.9.2
response.getCharset() the result is “Error during evaluation:Wrapped java.lang.NullPointerException”
response.getResponseHeaders() the result is {content-length:[“146”],content-type:[“text/html”],date:[“Fri, 23 Dec 2022 17:21:39 GMT”],server:[“nginx”]}

JuanMartin:
These are some result of probe with the Servoy version 22.6 and Servoy version 22.9.02 after response=getRequest.executeRequest() at the same Prestahop portal

With Servoy 22.6
response.getCharset() the result is “utf-8”
response.getResponseHeaders() the result is {Access-Time:[“1671815330”],Connection:[“keep-alive”],Content-Sha1:[“19207521eda9cef310e5eb0d73cf10b14cf91904”],Content-Type:[“text/xml;charset=utf-8”],Date:[“Fri, 23 Dec 2022 17:08:50 GMT”],Execution-Time:[“0.041”],Keep-Alive:[“timeout=15”],PSWS-Version:[“1.7.8.6”],Server:[“Apache”],Transfer-Encoding:[“chunked”],X-Powered-By:[“PrestaShop Webservice”]}

With Servoy 22.9.2
response.getCharset() the result is “Error during evaluation:Wrapped java.lang.NullPointerException”
response.getResponseHeaders() the result is {content-length:[“146”],content-type:[“text/html”],date:[“Fri, 23 Dec 2022 17:21:39 GMT”],server:[“nginx”]}

Can you check with postman if the content-type header does include the encoding? The new version of the http-plugin is less forgiving in this regard: Jira.

This is the process to read a category in Prestashop:

var url='https://xxxxxxxxxxxxxxx@domain/api/categories/?display=full&filter[name]=[category];
cliHttp =plugins.http.createNewHttpClient();
var getRequest = cliHttp.createGetRequest(url);
response=getRequest.executeRequest();

This works in servoy server, but in Developer always return 404 Error

This is the process to send an image:
var url = 'https://xxxxxxxxxxxxxxxx@domain/api/images/products/id_product;
cliHttp = plugins.http.createNewHttpClient();
postRequest = cliHttp.createPostRequest(url);
postRequest.addHeader(‘enctype’, ‘multipart/form-data’);
postRequest.addHeader(‘method’, ‘POST’);
postRequest.addParameter(‘Content-Type’, content);
postRequest.addFile(‘image’, tempFile);
response = postRequest.executeRequest();

This does not work neither in developer nor in server
It always returns that the image sent is not correct

Please, need fix this problem is 2022.9.2

do test this with viewtopic.php?f=1&t=23679

for 09 there won’t be any other release

If you still have this same problem with 12 we need a case, where we can do that exact post, to see what goes wrong there.

what you also can do is add this:

to the log4j.xml file

that will then generate a lot of httpclient traffic in the servoy_log.txt file \

And you can compare that with what postman does send

I have installed 2022.12 and have the same problem

I think my only option is to downgrade to 2022.6

you need to check what goes wrong.
If you are downgrading, you are stuck, 06 will never change

Did you look what the output is? did you add the logger?

My feeling is that the server can’t handle chunked encoding what the http client by default does now.
(if you are sending big files)

so it could be that you really need to set the “Content-Length” now yourself.

I have customers stopped with this topic
I have to solve the problem urgently and the fastest way is to downgrade and then I’ll start testing with 12, because it’s currently a beta

JuanMartin:
These are some result of probe with the Servoy version 22.6 and Servoy version 22.9.02 after response=getRequest.executeRequest() at the same Prestahop portal

With Servoy 22.6
response.getCharset() the result is “utf-8”
response.getResponseHeaders() the result is {Access-Time:[“1671815330”],Connection:[“keep-alive”],Content-Sha1:[“19207521eda9cef310e5eb0d73cf10b14cf91904”],Content-Type:[“text/xml;charset=utf-8”],Date:[“Fri, 23 Dec 2022 17:08:50 GMT”],Execution-Time:[“0.041”],Keep-Alive:[“timeout=15”],PSWS-Version:[“1.7.8.6”],Server:[“Apache”],Transfer-Encoding:[“chunked”],X-Powered-By:[“PrestaShop Webservice”]}

With Servoy 22.9.2
response.getCharset() the result is “Error during evaluation:Wrapped java.lang.NullPointerException”
response.getResponseHeaders() the result is {content-length:[“146”],content-type:[“text/html”],date:[“Fri, 23 Dec 2022 17:21:39 GMT”],server:[“nginx”]}

so in 2022.9.2 you get an error message instead of actual response, but which is the error message ? so response.getResponseText() , what does it have ?

When I try to read a category, for example
On developer response.getResponseBody() I have:

404 Not Found

404 Not Found


nginx

On servoy server this works fine, only have problem with some characters like “ñ”.

When I try to send an image, dosen´t work. On response.getResponseBody() I have:

<?xml version="1.0" encoding="UTF-8"?>

what happens if you just do this:

var url = 'https://xxxxxxxxxxxxxxxx@domain/api/images/products/id_product;
cliHttp = plugins.http.createNewHttpClient();
postRequest = cliHttp.createPostRequest(url);
postRequest.forceMultipart(true);
postRequest.addFile('image', tempFile);
response = postRequest.executeRequest();

The same response

very weird, as far as i see that is then what we send
then we must be able to reproduce it (so we need to be able todo exactly what you do )

or enable what i said above:

to the log4j.xml fil

so we have all the output of the wire what is being send

This is the content of servoy log in developer when I try to red a category

2022-12-29 11:53:35,778 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][69][0][53] >> PRI * HTTP/2.0 50 52 49 20 2a 20 48 54 54 50 2f 32 2e 30 0d 0a
2022-12-29 11:53:35,779 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][69][0][53] >> SM 0d 0a 53 4d 0d 0a 0d 0a
2022-12-29 11:53:35,795 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][69][0][53] << … 00 00 12 04 00 00 00 00 00 00 03 00 00 00 08 00
2022-12-29 11:53:35,795 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][69][0][53] << … 04 00 01 00 00 00 05 00 ff ff ff 00 00 04 08 00
2022-12-29 11:53:35,795 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][69][0][53] << …… 00 00 00 00 7f ff 00 00
2022-12-29 11:53:35,803 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][74] >> …$… … 00 00 24 04 00 00 00 00 00 00 01 00 00 20 00 00
2022-12-29 11:53:35,804 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][74] >> … 02 00 00 00 01 00 03 00 00 00 fa 00 04 00 00 ff
2022-12-29 11:53:35,804 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][74] >> … ff 00 05 00 01 00 00 00 06 00 ff ff ff
2022-12-29 11:53:35,804 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][42] >> …… 00 00 04 08 00 00 00 00 00 7f ff 00 00
2022-12-29 11:53:35,804 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][38] >> … 00 00 00 04 01 00 00 00 00
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> …u…A.{.! 00 00 75 01 05 00 00 00 01 82 87 41 a4 7b 94 21
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> …,X…o…x0.o… e7 f8 ce 2c 58 f1 f3 6f 87 2e 78 30 e9 6f f5 be
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> Y0i…?..r 59 30 69 fc c3 bd c7 ff 3f f5 18 e9 8c d5 19 72
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> .D.`u… %…c… a3 44 a9 60 75 99 82 0d 25 98 f6 18 a8 63 fc 90
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> …[h…SP… c8 ae 81 fa 82 5b 68 a3 e2 53 50 92 d9 ff ba 87
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> I…Q…z… 49 7f f9 07 fe ee 8e 98 cd 51 bf f9 7a a0 86 b1
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> .r…)…z…1jK . 92 72 ad 8d 29 ae 14 7a a8 97 a8 31 6a 4b 0d ae
2022-12-29 11:53:35,805 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:w][ACTIVE][rw][NOT_HANDSHAKING][0][0][155] >> …}…B… … 15 c4 a7 f5 94 7d c6 c0 42 b8 17 0b 9f df
2022-12-29 11:53:35,873 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][r:r][ACTIVE][r][NOT_HANDSHAKING][38][0][0] << … 00 00 00 04 01 00 00 00 00
2022-12-29 11:53:35,873 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << … .v…cU 00 00 2e 01 04 00 00 00 01 20 8d 76 84 aa 63 55
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << .a…=.J ./… e7 61 96 df 3d bf 4a 09 f5 2f 94 8a 08 02 12 81
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << …b…_.I|… 0d c6 d9 b8 cb 8a 62 d1 bf 5f 87 49 7c a5 89 d3
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << M .146… 4d 1f 5c 03 31 34 36 00 00 92 00 01 00 00 00 01
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << <t 3c 68 74 6d 6c 3e 0d 0a 3c 68 65 61 64 3e 3c 74
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << itle>404 Not Fou 69 74 6c 65 3e 34 30 34 20 4e 6f 74 20 46 6f 75
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << nd</head 6e 64 3c 2f 74 69 74 6c 65 3e 3c 2f 68 65 61 64
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << > <cent 3e 0d 0a 3c 62 6f 64 79 3e 0d 0a 3c 63 65 6e 74
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << er>

404 Not F 65 72 3e 3c 68 31 3e 34 30 34 20 4e 6f 74 20 46
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << ound

</cente 6f 75 6e 64 3c 2f 68 31 3e 3c 2f 63 65 6e 74 65
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << r>
72 3e 0d 0a 3c 68 72 3e 3c 63 65 6e 74 65 72 3e
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << nginx 6e 67 69 6e 78 3c 2f 63 65 6e 74 65 72 3e 0d 0a
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << 3c 2f 62 6f 64 79 3e 0d 0a 3c 2f 68 74 6d 6c 3e
2022-12-29 11:53:35,874 DEBUG [httpclient-dispatch-1] org.apache.hc.client5.http.wire - c-0000000000[ACTIVE][rw:r][ACTIVE][rw][NOT_HANDSHAKING][277][0][0] << 0d 0a

thats not really enough, we need a lot more, like the portion of the request where you see all the headers and son.
that part only seems the response

No there are nay more about this in servoy_log.txt

I created a demo server of Prestashop for you.

No there are nothing in it, I only create some categories for try to read

This is the url for read all categories

https://TS77M53GHATMHUP5Y5F4PSFI1YVFT24 … ategories/?

This url works in Postman

Try to read the same url on developer

cliHttp =plugins.http.createNewHttpClient();
var getRequest = cliHttp.createGetRequest(url);
response=getRequest.executeRequest();

this works fine:

var url = “https://idealjoyeros.es/api/categories/
var cliHttp =plugins.http.createNewHttpClient();
var getRequest = cliHttp.createGetRequest(url);
getRequest.usePreemptiveAuthentication(true);
var response=getRequest.executeRequest(“TS77M53GHATMHUP5Y5F4PSFI1YVFT24A”, “a”);
application.output(response.getResponseBody())

the problem is i guess http client 5 doesnt support those urls with the username directly in the name.
also it doesn’t support empty passwords i think, so thats why i just paste in “a”

then i get the response just fine,