Team
I am also getting Error “Daily quota reached or API key unauthorized!” . Please find the uploaded screen shot for reference.
My Input Latitude and Longitude is : {locations:[[8.609168, 49.893230],[8.589405, 50.055435]]}
var baseAddress = new Uri(“https://api.openrouteservice.org”);
string responseData = “”;
using (var httpClient = new HttpClient { BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));
httpClient.DefaultRequestHeaders.Authorization =new AuthenticationHeaderValue(“Authorization”, “xxx”);
var SensorLocationsData = _notiUnitOfWork.NotificationRepository.GetLastSensorLocationData();
string locations = "{locations:[locs]}";
string loc = string.Empty;
foreach (var SensorLocations in SensorLocationsData)
{
string str = string.Format("[{0}, {1}]", SensorLocations.Longitude, SensorLocations.Latitude);
if (str != "")
loc += str + ",";
}
locations = locations.Replace("locs", loc.Substring(0, loc.Length - 1));
using (var content = new StringContent(locations))
{
using (HttpResponseMessage response = httpClient.PostAsync("/v2/matrix/driving-car", content).Result)
{
responseData = response.Content.ReadAsStringAsync().Result;
}
}
}
string jsonString = JsonConvert.SerializeObject(responseData);
return new JsonResult() { Data = jsonString, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
Thanks,
Vamsi