delphi-rest-client-api icon indicating copy to clipboard operation
delphi-rest-client-api copied to clipboard

Getting http error

Open danilobicas-unoeste opened this issue 6 years ago • 1 comments

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

danilobicas-unoeste avatar Mar 16 '18 17:03 danilobicas-unoeste

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;

thomaserlang avatar Mar 16 '18 20:03 thomaserlang