Jump to content
annie_cyy@yahoo.ca

REST request failed: Error sending data: (12152) The server returned an invalid or unrecognized response

Recommended Posts

Tool is Delphi XE 10.3,

In Windows 8 or Windows10  run perfect, but run in Windows 7 , it got error message like title

" REST request failed: Error sending data: (12152) The server returned an invalid or unrecognized response" .

Somebody can help me?  

 

procedure TForm1.MCloud_Prepare_RequestR();
var
    __securityAppName   : String;
    __searchSymbol      : String;
    __globalID          : String;
begin
     RESTRequest.Method := TRESTRequestMethod.rmPOST;
     RESTClient.Accept:='multipart/form-data';
     RESTClient.BaseURL := CURL+':Port#/v1/auth/token';
     RESTClient.ProxyPort:=9999;
     RESTClient.ProxyServer:=CURL;
     RESTClient.ProxyUsername:='CloudTest';
     RESTRequest.AcceptEncoding:='UTF8';
     RESTRequest.AddParameter('id','12345',TRESTRequestParameterKind.pkREQUESTBODY);
     RESTRequest.AddParameter('client_id',CCLIENT_ID,TRESTRequestParameterKind.pkREQUESTBODY);
     RESTRequest.AddParameter('secret',CSECRET,TRESTRequestParameterKind.pkREQUESTBODY);

    RESTRequest.Execute;
end;

Edited by annie_cyy@yahoo.ca

Share this post


Link to post

There are a lot of things wrong with this code.  The first thing that stands out to me is the BaseURL and ProxyServer are using the same Host/IP, why? That makes no sense to me. Also, if you are trying to *send* a request in 'multipart/form-data' format, you should be setting that in the 'Content-Type' request header, not in the 'Accept' request header.  Also, 'UTF8' is not a valid content encoding for the 'Accept-Encoding' request header.

 

Can you provide some details about what the REST API is actually expecting you to send to it?

Edited by Remy Lebeau

Share this post


Link to post

Thank you so much. This is my first time writing for cloud. I'm confused, in Win10 or Win8 it works fine, but in Win7 it still works if I send it using "HTTP", but I get an error message when I send it using "https:".
Is it a secure issue? 

CURL= 'https://Testme.aaaa.com';

Share this post


Link to post

Make sure you override the default registry settings e.g. something like

 

RestClient.SecureProtocols:=[THTTPSecureProtocol.TLS12,THTTPSecureProtocol.TLS13];

 

Share this post


Link to post
1 hour ago, annie_cyy@yahoo.ca said:

RestClient.SecureProtocols:= [THTTPSecureProtocol.SSL2],...

This protocol is deprecated long ago. TLS1.2 is minimal actual protocol now

Share this post


Link to post
On 1/11/2022 at 4:15 PM, annie_cyy@yahoo.ca said:

Thank you so much. This is my first time writing for cloud.

You didn't address my question about the ProxyServer, do you really need that, and why is it being set to the same server as the BaseURL?

Quote

I'm confused, in Win10 or Win8 it works fine, but in Win7 it still works if I send it using "HTTP"

It's possible that the HTTP server is redirecting the request to the HTTPS server, which the REST component is likely handling internally.

Quote

but I get an error message when I send it using "https:".
Is it a secure issue?

I can't answer that.  It is hard to diagnose without seeing the actual HTTP data on the network.

On 1/11/2022 at 11:51 PM, Fr0sT.Brutal said:

This protocol [SSL2] is deprecated long ago. TLS1.2 is minimal actual protocol now

That is debatable.  TLS 1.1 is still fairly common.  At a MINIMUM, don't go below TLS 1.0.  Most servers have phased out TLS 1.0, and are phasing out TLS 1.1, but they still exist in the wild.

Edited by Remy Lebeau

Share this post


Link to post
20 hours ago, Remy Lebeau said:

That is debatable.  TLS 1.1 is still fairly common.  At a MINIMUM, don't go below TLS 1.0.  Most servers have phased out TLS 1.0, and are phasing out TLS 1.1, but they still exist in the wild.

Well, with "actual" I wanted to say non-officially-deprecated.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×