The Get request should result in this Curl command :
curl -X GET --header 'Accept: application/json' --header 'X-API-KEY: xxxxxxxx' 'https://app.atera.com/api/v3/agents'
Response Header :
{
"access-control-expose-headers": "Request-Context",
"cache-control": "no-cache",
"cf-cache-status": "DYNAMIC",
"cf-ray": "8dc1f2e679b09240-MUC",
"content-encoding": "gzip",
"content-length": "1123",
"content-type": "application/json; charset=utf-8",
"date": "Sat, 02 Nov 2024 06:08:14 GMT",
"expires": "-1",
"pragma": "no-cache",
"request-context": "appId=cid-v1:3dc4fe10-3963-411c-94fc-eee1cd3ba929",
"server": "cloudflare",
"vary": "Accept-Encoding",
"x-aspnet-version": "4.0.30319",
"x-powered-by": "ASP.NET"
}
More information on the TTMSFNCRESTClient can be found here: TMSFNCRESTClient - TMS FNC Cloud Pack
To add headers to the request you can use: TMSFNCRESTClient.Request.Headers.AddHeader('X-API-KEY', 'xxxxxxxx');
Or is there anything else specific that you would need?
Thank you for the key, so we could test.
It appears that the API is blocking the User-Agent name, created by Windows.
You can easily change this by adding it as a header.
procedure DoRetrieve(Sender: TObject; ARequest: TTMSFNCRESTClientExecutedRequest; AResultString: string; AResultStream: TMemoryStream; AResultFile: string);
procedure Response(const ARequestResult: TTMSFNCCloudBaseRequestResult);
r := TTMSFNCRESTClient.Create(Self);
r.OnRequestResponseRetrieved := DoRetrieve;
r.Request.Clear;
r.Request.Method := rmGet;
r.Request.URL := 'https://app.atera.com/api/v3/agents';
r.Request.Headers.AddHeader('User-Agent', 'MyApp');
r.Request.Headers.AddHeader('x-api-key','xxxxxx');
r.ExecuteRequest;
//or
cb := TTMSFNCCloudBase.Create;
cb.Request.Host := 'https://app.atera.com';
cb.Request.Path := '/api/v3/agents';
cb.Request.AddHeader('x-api-key','xxxxx');
cb.Request.AddHeader('User-Agent', 'MyApp');
cb.ExecuteRequest(Response);
Thank you Gjalt,
to have it at design time a had to change the headers
regards Wolfgang
Ps:
The API Key is devalued
Is there a best practice to manage ALL API requests in a database ( table ),
or is it necessary to create all these delphi classes to manipulate the data ?
I'm very sorry but could you elaborate a little more on what you want?
For the moment the requests with the responses are stored in the history tab of REST Insight, but nothing else happens with those.
Do you have a link to a block post concerning
Pipeline : API -> Rest Client -> JSon -> Delphi Class -> (Aurelius ?) -> Database ?
thanks in advanced, Wolfgang
For the moment we do not have such a blogpost.
Sorry for the inconvenience.