Sorry if this is in the wrong place, I wasn't sure where to put it.
I honestly cannot believe how difficult I have found googling this question.
I would have thought it was really obvious, if you need to include an API key, then how do you go about putting that into your get request/application - there is a LOT of information about how to build an API which requires an API key, but I don't know whether I have entirely misunderstood the basis of the existence of the API key?
I found one topic on Stack Overflow about this, and the links are all dead, the documentation and code examples on MSDN are gone, searching for them reveals nothing. This may well be an old and dead method, but I still kinda need it.
Anyone have a good primer on this that isn't about building an API with an API key generation? I have put some code below that comes from I Am Tim Corey - whose demo on using API's I was learning from...
Thanks!
I honestly cannot believe how difficult I have found googling this question.
I would have thought it was really obvious, if you need to include an API key, then how do you go about putting that into your get request/application - there is a LOT of information about how to build an API which requires an API key, but I don't know whether I have entirely misunderstood the basis of the existence of the API key?
I found one topic on Stack Overflow about this, and the links are all dead, the documentation and code examples on MSDN are gone, searching for them reveals nothing. This may well be an old and dead method, but I still kinda need it.
Anyone have a good primer on this that isn't about building an API with an API key generation? I have put some code below that comes from I Am Tim Corey - whose demo on using API's I was learning from...
Thanks!
C#:
public static async Task<SunModel> LoadSunInformation()
{
string url = "https://api.sunrise-sunset.org/json?lat=51.531288&lng=0.017781&date=today";
using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
{
if (response.IsSuccessStatusCode)
{
SunResultModel result = await response.Content.ReadAsAsync<SunResultModel>();
return result.Results;
}
else
{
throw new Exception(response.ReasonPhrase);
}
}
}