Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get response content even if connection gives error in IdHttp?

When using TIdHttp like this:

Memo1.Text := IdHTTP1.post(url,data);

I can get response content to memo1 if it doesn't give http error. But when it gives http bad request, Indy doesn't give me content. I'm also using try..except but it only prevent error box and still doesn't give me content.

How can I get content even it returns http error?

like image 358
Someone Avatar asked Aug 31 '13 14:08

Someone


Video Answer


1 Answers

When an HTTP error occurs, TIdHTTP raises an EIdHTTPProtocolException exception. That exception contains the HTTP status code in its ErrorCode property, the HTTP status text in its Message property, and the response data in its ErrorMessage property.

like image 64
Remy Lebeau Avatar answered Sep 28 '22 01:09

Remy Lebeau