schttpwebrequest response

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
clement75
Posts: 5
Joined: Tue 06 Jul 2021 05:52

schttpwebrequest response

Post by clement75 » Wed 18 Aug 2021 09:03

Hi,
i use the schttpwebrequest to connect one URL in delphi program
it can receive the response when the response is:
{
"success": true
}

however, it raise exception (Bad Request) when the server return the below message:
{
"success": false,
"error": "Given code / id does not exists "
}

the error happens in the below code:
Response := ScHttpWebRequest1.GetResponse;


Anyone know how can i get/read the data returned from the server?


Thank You.

YanishevskiyVI
Devart Team
Posts: 70
Joined: Wed 02 Jun 2021 09:30

Re: schttpwebrequest response

Post by YanishevskiyVI » Thu 19 Aug 2021 12:04

Hi Clement!

Thank you for your question!

In order to get data returned by server you need to handle HttpException. Try to do this:

Code: Select all

  try
    Response := ScHttpWebRequest1.GetResponse; 
  except
    on E:HttpException do
      showmessage(E.ServerMessage);
  end;
In this case E.ServerMessage will contain all data returned by server.

Please, let us know if tere are any questions!

Regards,
Vitaliy
Devart team

clement75
Posts: 5
Joined: Tue 06 Jul 2021 05:52

Re: schttpwebrequest response

Post by clement75 » Fri 20 Aug 2021 01:27

thanks for your reply.
it works!

YanishevskiyVI
Devart Team
Posts: 70
Joined: Wed 02 Jun 2021 09:30

Re: schttpwebrequest response

Post by YanishevskiyVI » Fri 20 Aug 2021 11:07

Hi Clement!

Thank you for your reply!

I am glad to know that the issue was resolved successfully for you!

In case you meet any other issues or have any questions please feel free to contact us back.

Regards,
Vitaliy

Post Reply