Page 1 of 1

TScHttpWebRequest and GetResponse Exception

Posted: Wed 03 Apr 2019 09:42
by jensgott
I have a problem with TScHttpWebRequest.

When I call GetResponse from a webservices returning status code 403, I get an exception telling me that this code has been return. But I have no way of getting the data send with this status code?

If I call TScHttpWebRequest's ReadBuffer I only get what I did send

Is there anyway to avoid the GetResponse raise an exception, which is not a logical solution in my opion. Or at lease get the data send from the webservice?

Re: TScHttpWebRequest and GetResponse Exception

Posted: Wed 03 Apr 2019 14:06
by ViktorV
When the server returned an error status 403 and there is some additional information, then to access this information, you can use the HttpException.ServerMessage property. For example:

Code: Select all

  try
    Response := Request.GetResponse;
  except
    on E: HttpException do
      if HttpException(E).StatusCode = scForbidden then
        s := HttpException(E).ServerMessage;
  end;

Re: TScHttpWebRequest and GetResponse Exception

Posted: Thu 04 Apr 2019 08:10
by jensgott
Thank you - works great.

BTW: ServerMessage is not documentet in the help for HttpException

Re: TScHttpWebRequest and GetResponse Exception

Posted: Thu 04 Apr 2019 08:57
by ViktorV
It is good to see that the problem has been solved.
Thank you for the information. We will add the necessary information in SecureBridge help in the next version of SecureBridge.
Feel free to contact us if you have any further questions about our products.