fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
381 stars 182 forks source link

Getting http error #114

Open danilobicas-unoeste opened 6 years ago

danilobicas-unoeste commented 6 years ago

Hi. How I get the http error, for example:

Result:= TObjectList(meuRest.Resource(UrlApi + '/api/TipoMovimento') .Accept(RestUtils.MediaType_Json) .Authorization('Bearer '+MDToken['access_token']) .Get(TObjectList, TipoMovimentoViewModel)); If I get error of 401... how I know the error in code... in debugmode in delphi I get a message like ..... HTTP 401......... How I get this error in my code?

Tk's

DAnilo

thomaserlang commented 6 years ago

You catch it as an exception.

try
  // your rest call
except
    on e: EHTTPError do
    begin
        // e.ErrorCode will contain the response code
    end;
end;