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.
schttpwebrequest response
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: schttpwebrequest response
Hi Clement!
Thank you for your question!
In order to get data returned by server you need to handle HttpException. Try to do this:
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
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;
Please, let us know if tere are any questions!
Regards,
Vitaliy
Devart team
Re: schttpwebrequest response
thanks for your reply.
it works!
it works!
-
- Devart Team
- Posts: 70
- Joined: Wed 02 Jun 2021 09:30
Re: schttpwebrequest response
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
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