Accessing APIs is new territory for me. I am trying to access an API using TNetHttpClient component. The curl example provided is:
curl --request GET 'https://api.samsara.com/fleet/vehicles/stats' \
-d types='engineStates' \
-d decorations='gps' \
--header 'Authorization: Bearer TOKEN' \
-G
I have been unsuccessful at using various settings of TNetHttpClient to get the authorization. I have the proper token but everything I try, I get the results "message":"invalid token" followed by the request id.
My latest attempt is below but same results. Can anyone advice and perhaps provide sample code of how to accomplish this? Thank you in advance.
var
Params: TStringList;
begin
Params :=TStringList.Create;
Params.Add('types = engineStates');
Params.Add('decorations=gps');
http1.CustHeaders.Add('Authorization', '<My Token>'); //<My Token replaced with actual token
memo2.Lines.Text :=http1.Post('https://api.samsara.com/fleet/vehicles/stats', Params).ContentAsString;
end;