Plugin Http client Error 404

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Re: Plugin Http client Error 404

Postby jcompagner » Thu Dec 29, 2022 11:57 am

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:

<Logger name="org.apache.hc.client5.http.wire" level="DEBUG">
</Logger>

to the log4j.xml fil

so we have all the output of the wire what is being send
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Thu Dec 29, 2022 1:58 pm

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] << <html> <head><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</title></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] << > <body> <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><h1>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</h1></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> <hr><center> 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</center> 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] << </body> </html> 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 [ ]
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby jcompagner » Thu Dec 29, 2022 2:41 pm

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
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Thu Dec 29, 2022 3:30 pm

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();
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby jcompagner » Thu Dec 29, 2022 3:59 pm

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,
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Fri Dec 30, 2022 3:15 pm

Ok, now works all but there are errors with upload image:

https://idealjoyeros.es/api/images/products/30"
cliHttp = plugins.http.createNewHttpClient();
var postRequest = cliHttp.createPostRequest(url);
postRequest.addHeader('enctype', 'multipart/form-data');
postRequest.addHeader('method', 'POST');
postRequest.addParameter('Content-Disposition', 'form-data;name="image"');
postRequest.addParameter('Content-Type', content);
postRequest.addFile('image', tempFile);
postRequest.usePreemptiveAuthentication(true);
postRequest.forceMultipart(true);
response = postRequest.executeRequest(_sa.presta_clientes ,"a");
result = utils.stringReplace(response.getResponseBody(), "><", ">\n<");

response.getResponseBody is:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code>
<![CDATA[76]]>
</code>
<message>
<![CDATA[Please set an "image" parameter with image data for value]]>
</message>
</error>
</errors>
</prestashop>
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby lvostinar » Tue Jan 03, 2023 11:07 am

I managed to reproduce the post error and looking into it, see https://support.servoy.com/browse/SVY-17814
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Plugin Http client Error 404

Postby lvostinar » Tue Jan 03, 2023 2:07 pm

If I try the sample above I get the same error in older Servoy releases, are you sure this code used to work? I think the server has some problem with the image validation , but not sure how to fix it. See https://www.prestashop.com/forums/topic ... oad-photo/ for someone that had the same issue ? So, I think this is not a Servoy bug, is just that we don't set something as they expect? Maybe you can find a clue on their forum ?
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Plugin Http client Error 404

Postby JuanMartin » Tue Jan 03, 2023 2:43 pm

With Servoy version 22.06 this code works fine:

var url = 'https://webservice_id@domain/api/images/products/30;

cliHttp = plugins.http.createNewHttpClient();
cliHttp.setTimeout(50000);
var postRequest = cliHttp.createPostRequest(url);
postRequest.addHeader('enctype', 'multipart/form-data');
postRequest.addHeader('method', 'POST');
postRequest.addParameter('Content-Disposition', 'form-data;name="image"');
postRequest.addParameter('Content-Type', content);
postRequest.addFile('image', tempFile);
response = postRequest.executeRequest();

I don't know exactly what is changing internally in the http protocol, but there is something different that affects this process
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby jcompagner » Thu Jan 05, 2023 11:17 am

i attached the latest http jar that has some multiplart fixes to set in http/1 mode the right content-length

now it works for you example if you use http instead of https

IF you use https then the new http client will use (because the server replies like that) http/2 mode.

The thing is in http/2 mode the content-length header is optional, and the apache http client doesn't set that then anymore.

And that server can't handle that, it finds that content-length header a mandatory thing to have (you get that give image param if you don't have that set)
but http/2 spec states its not needed anymore so or that server should not say it supports http/2 or it should work correctly in http/2 and not bother about that length being set or not.
Attachments
http.jar
latest http plugin
(93.77 KiB) Downloaded 123 times
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Thu Jan 05, 2023 2:30 pm

Great, works perfectly

Thanks a lot
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby jcompagner » Thu Jan 05, 2023 3:20 pm

but it only works in http mode not https mode to that server
and you are sending over credentials so you should be using https
but that will then map on http/2 and then you will get the same warning about "image" not there even if we are sending the exact same thing over (except not setting the content-length header)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Thu Jan 05, 2023 3:33 pm

If I pass the url as http://webservive............
instead of https://webservice.......
It is sending it to me correctly
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Plugin Http client Error 404

Postby jcompagner » Thu Jan 05, 2023 5:12 pm

yes thats what i told you and that is a problem!
you should be uing httpS !
because you are also using basic authentication! so that user information. that should never be transmitted over plain http...


The server should work in httpS (http/2) mode correctly, they need to fix that.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Plugin Http client Error 404

Postby JuanMartin » Thu Jan 05, 2023 7:28 pm

It is something that Prestashop itself manages.
I can only activate or deactivate https on the web and activate or deactivate the webservice.
I can't manage anything else
Juan Antonio Martín Pinilla
Servoy 2022.9.2 - PostgreSql 9.4
software@critenerife.com
User avatar
JuanMartin
 
Posts: 169
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

PreviousNext

Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 7 guests