Reputation: 738
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?
Upvotes: 5
Views: 6589
Reputation: 596226
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.
Upvotes: 7
Reputation: 293
try this code
Try
Memo1.Text := IdHTTP1.post(url,data);
except on e: EIdHTTPProtocolException do
begin
memo1.lines.add(idHTTP1.response.ResponseText);
memo1.lines.add(e.ErrorMessage);
end;
e.ErrorMessage will give you some informations about the bad request.
Upvotes: 3