Page 1 of 3

Plugin Http client Error 404

PostPosted: Thu Dec 22, 2022 8:44 pm
by JuanMartin
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

Re: Plugin Http client Error 404

PostPosted: Fri Dec 23, 2022 1:55 pm
by robert.edelmann
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.

Re: Plugin Http client Error 404

PostPosted: Fri Dec 23, 2022 2:52 pm
by jcompagner
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

Re: Plugin Http client Error 404

PostPosted: Fri Dec 23, 2022 7:01 pm
by JuanMartin
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

Re: Plugin Http client Error 404

PostPosted: Fri Dec 23, 2022 7:29 pm
by 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"]}

Re: Plugin Http client Error 404

PostPosted: Sat Dec 24, 2022 2:23 pm
by robert.edelmann
JuanMartin wrote: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: https://support.servoy.com/browse/SVY-17640.

Re: Plugin Http client Error 404

PostPosted: Mon Dec 26, 2022 1:20 pm
by JuanMartin
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

Re: Plugin Http client Error 404

PostPosted: Tue Dec 27, 2022 10:46 am
by jcompagner
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:

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

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

Re: Plugin Http client Error 404

PostPosted: Tue Dec 27, 2022 12:05 pm
by JuanMartin
I have installed 2022.12 and have the same problem

I think my only option is to downgrade to 2022.6

Re: Plugin Http client Error 404

PostPosted: Tue Dec 27, 2022 12:45 pm
by jcompagner
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.

Re: Plugin Http client Error 404

PostPosted: Tue Dec 27, 2022 12:58 pm
by JuanMartin
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

Re: Plugin Http client Error 404

PostPosted: Wed Dec 28, 2022 5:15 pm
by lvostinar
JuanMartin wrote: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 ?

Re: Plugin Http client Error 404

PostPosted: Thu Dec 29, 2022 9:46 am
by JuanMartin
When I try to read a category, for example
On developer response.getResponseBody() I have:

<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<center>
<h1>404 Not Found</h1>
</center>
<hr>
<center>nginx</center>
</body>
</html>

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"?>
<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>

Re: Plugin Http client Error 404

PostPosted: Thu Dec 29, 2022 10:52 am
by jcompagner
what happens if you just do this:

Code: Select all
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();

Re: Plugin Http client Error 404

PostPosted: Thu Dec 29, 2022 11:12 am
by JuanMartin
The same response

<![CDATA[Please set an "image" parameter with image data for value]]>