07-11-2019, 10:46 PM
I am trying to post weather data to the OpenWeatherMap API server.
They use a RESTful server (API 3.0).
The documentation on this is totally incomplete.
Using a third-party program called 'ARC' and a lot of research, I discovered that in addition to adding the KEY to the URL, it is also required that *before* the HTTP Request the same KEY is send, which in this ARC program is called an 'Action', with a 'Name' and a 'value'.
In another application reference on the Internet the same name+value where added in what was called the 'Params' of this application.
The only Params I have been able to find in the IdHTTP Client is here:
IdHTTP1.Request.Authentication.Params.AddValue('appid',APIKey);
But this cannot be done because the 'Authentication' is not created.
And when I try to create it manually, I get a
[dcc32 Warning] Unit1.pas(224): W1020 Constructing instance of 'TIdAuthentication' containing abstract method 'TIdAuthentication.DoNext'
I am not even sure if this is the right location for this 'name' + 'Key'.
The OpenWeatherMap API does not do any negotiation; When the HTTP Post is not excactly correct, it just gives a '400' and disconnects.
OnAuthorisation and OnSelectAuthorisation are never called.
How am I to add these values to the HTTP Post, *before* the body containing JSON data is send?
They use a RESTful server (API 3.0).
The documentation on this is totally incomplete.
Using a third-party program called 'ARC' and a lot of research, I discovered that in addition to adding the KEY to the URL, it is also required that *before* the HTTP Request the same KEY is send, which in this ARC program is called an 'Action', with a 'Name' and a 'value'.
In another application reference on the Internet the same name+value where added in what was called the 'Params' of this application.
The only Params I have been able to find in the IdHTTP Client is here:
IdHTTP1.Request.Authentication.Params.AddValue('appid',APIKey);
But this cannot be done because the 'Authentication' is not created.
And when I try to create it manually, I get a
[dcc32 Warning] Unit1.pas(224): W1020 Constructing instance of 'TIdAuthentication' containing abstract method 'TIdAuthentication.DoNext'
I am not even sure if this is the right location for this 'name' + 'Key'.
The OpenWeatherMap API does not do any negotiation; When the HTTP Post is not excactly correct, it just gives a '400' and disconnects.
OnAuthorisation and OnSelectAuthorisation are never called.
How am I to add these values to the HTTP Post, *before* the body containing JSON data is send?