delphi-rest-client-api
delphi-rest-client-api copied to clipboard
Getting http error
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
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;