# 403 Forbidden - Daily quota reached or API key unauthorized

**URL:** https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495
**Category:** openrouteservice
**Created:** [May 5, 2019, 6:00pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495 "2019-05-05T18:00:00Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Juan\_Atenas](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@Juan\_Atenas](https://ask.openrouteservice.org/u/Juan_Atenas)
#### Post date: [May 5, 2019, 6:00pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/1 "2019-05-05T18:00:00Z")

</div>

I am using the free version and the message always appears  
403 ({‘error’: ‘Daily quota reached or API key unauthorized’})

that could be happening?

Thank you!  
Regards,  
Juan

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [May 5, 2019, 6:01pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/2 "2019-05-05T18:01:09Z")

</div>

Exactly what it says, I guess. Either your API key is not valid or you reached the daily quota.

An example query would surely help.

---

<div class="post-metadata">

### Author: ![Juan\_Atenas](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@Juan\_Atenas](https://ask.openrouteservice.org/u/Juan_Atenas)
#### Post date: [May 8, 2019, 3:21pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/3 "2019-05-08T15:21:44Z")

</div>

the key api is correct, and I have not reached the daily quota, this is my code

using System;  
using System.Net.Http;  
using System.Net.Http.Headers;  
using System.Threading.Tasks;

namespace Ruta  
{  
class Program  
{  
static async Task Main(string[] args)  
{

```
        var baseAddress = new Uri("https://api.openrouteservice.org");

        using (var httpClient = new HttpClient { BaseAddress = baseAddress })
        {

            httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8");
            httpClient.DefaultRequestHeaders.Authorization =
                new AuthenticationHeaderValue("Authorization","5b3ce3597851110001cf6248985eba971d6a432982352355657a5ded");

            using (var content = new StringContent("{locations:[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]]}"))
            {
                using (var response = await httpClient.PostAsync("/v2/matrix/driving-car", content))
                {
                    string responseData = await response.Content.ReadAsStringAsync();
                }
            }
        }

    }
}

```

}

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [May 8, 2019, 3:34pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/4 "2019-05-08T15:34:12Z")

</div>

Ok, your key is valid, yep (not a good idea to make that public btw…).

Can you print the full URL, passed parameters and headers? It needs `Content-Type: application/json` and well, the POST request actually has to post a JSON object (not sure if your lib does that automatically from that string you pass). That shouldn’t result in this API error, but the rest actually looks fine to me.

---

<div class="post-metadata">

### Author: ![Juan\_Atenas](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@Juan\_Atenas](https://ask.openrouteservice.org/u/Juan_Atenas)
#### Post date: [May 8, 2019, 4:04pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/5 "2019-05-08T16:04:48Z")

</div>

I removed that code from the Open Route page,  
this is what returns me:

|response|{StatusCode: 403, ReasonPhrase: ‘Forbidden’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Connection: keep-alive Date: Wed, 08 May 2019 15:56:15 GMT Server: nginx/1.10.3 Server: (Ubuntu) Content-Length: 61 Content-Type: application/json }}|System.Net.Http.HttpResponseMessage|

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [May 9, 2019, 6:12am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/6 "2019-05-09T06:12:39Z")

</div>

We can’t help if you don’t give us one full exact HTTP request that fails: full URL, POST parameters and headers. Please print them in your debug window and paste them here (minus the Authorization header pls).

---

<div class="post-metadata">

### Author: ![Juan\_Atenas](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@Juan\_Atenas](https://ask.openrouteservice.org/u/Juan_Atenas)
#### Post date: [May 9, 2019, 7:53pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/7 "2019-05-09T19:53:11Z")

</div>

![depuracion](https://ask.openrouteservice.org/uploads/default/original/1X/f578f89341e8e6ab117023bdccc0919298b0a705.jpeg)

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [May 9, 2019, 8:07pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/8 "2019-05-09T20:07:19Z")

</div>

Paste. Please. This is not a nice way to request free support… And READ!! Your `content-type` is `text/plain`! If you use our POST endpoint, you have to POST a JSON, not a string! That’s what I was telling you here:

> Can you print the full URL, passed parameters and headers? It needs `Content-Type: application/json` and well, the POST request actually has to post a JSON object (not sure if your lib does that automatically from that string you pass). That shouldn’t result in this API error, but the rest actually looks fine to me.

---

<div class="post-metadata">

### Author: ![Juan\_Atenas](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/j/ce73a5/32.png) [@Juan\_Atenas](https://ask.openrouteservice.org/u/Juan_Atenas)
#### Post date: [June 10, 2019, 9:59pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/9 "2019-06-10T21:59:11Z")

</div>

The example is the one that you propose on your page

---

<div class="post-metadata">

### Author: ![amandus](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/amandus/32/669_2.png) [@amandus](https://ask.openrouteservice.org/u/amandus)
#### Post date: [June 10, 2019, 10:45pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/10 "2019-06-10T22:45:53Z")

</div>

Hi @Juan_Atenas,

This is C# i suppose? Due to limited human resources we cannot test every code example. They are generated automatically from a template which might not be working for C#.  
The problem should be with either the `AuthenticationHeaderValue` or the `TryAddWithoutValidation` part.  
If you get this to work, you might want to provide us with your solution, so other people won’t run into the same issue 🙂

regards, Amandus

---

<div class="post-metadata">

### Author: ![vamsi](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/v/b38774/32.png) [@vamsi](https://ask.openrouteservice.org/u/vamsi)
#### Post date: [November 30, 2019, 7:29pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/11 "2019-11-30T19:29:59Z")

</div>

Team

I am also getting Error “Daily quota reached or API key unauthorized!” . Please find the uploaded screen shot for reference.

 ![Error](https://ask.openrouteservice.org/uploads/default/original/1X/d3f99b3ad5bab9a4e7fbbcd693000d0ad4a13973.png)

My Input Latitude and Longitude is : {locations:[[8.609168, 49.893230],[8.589405, 50.055435]]}

var baseAddress = new Uri(“[https://api.openrouteservice.org](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

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [December 2, 2019, 6:27am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/12 "2019-12-02T06:27:13Z")

</div>

Please provide us with:

- the exact URL incl endpoint
- the POST body
- the headers

in a human-readable and reproducible format, i.e. text. C# must have the option to print a “debuggable” version of the request, e.g. [https://stackoverflow.com/questions/18924996/logging-request-response-messages-when-using-httpclient/35215502](https://stackoverflow.com/questions/18924996/logging-request-response-messages-when-using-httpclient/35215502)

---

<div class="post-metadata">

### Author: ![vamsi](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/v/b38774/32.png) [@vamsi](https://ask.openrouteservice.org/u/vamsi)
#### Post date: [December 2, 2019, 8:12am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/13 "2019-12-02T08:12:12Z")

</div>

Hallo Nils,

Please find the below details:

Exact URL incl endpoint : [https://api.openrouteservice.org/v2/matrix/driving-car](https://api.openrouteservice.org/v2/matrix/driving-car)

Headers: {Content-Type: text/plain; charset=utf-8 Content-Length: 57}

“error”: “Daily quota reached or API key unauthorized”

 ![Body](https://ask.openrouteservice.org/uploads/default/original/1X/f617b3b2399f86eaee21b54920edd7cf3edf1fda.png)  
 ![Error2](https://ask.openrouteservice.org/uploads/default/original/1X/58611cb425291a12c14a0541f44d6e57dc600976.png)

My complete code i posted in above posts.

Cheers  
Vamsi

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [December 2, 2019, 8:46am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/14 "2019-12-02T08:46:14Z")

</div>

Multiple things potentially wrong here:

`Content-Type: application/json` not `text`.

`Authorization: Bearer <key>`, not `Authorization <key>`.

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [December 2, 2019, 8:47am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/15 "2019-12-02T08:47:35Z")

</div>

Also, I don’t see your POST body… Please don’t make me look at screenshots:

> in a human-readable and reproducible format, i.e. text.

---

<div class="post-metadata">

### Author: ![vamsi](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/v/b38774/32.png) [@vamsi](https://ask.openrouteservice.org/u/vamsi)
#### Post date: [December 2, 2019, 11:53am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/16 "2019-12-02T11:53:48Z")

</div>

Hi Nils,

i changed from text to json as content type and Bearer Key

 ![Error%20New](https://ask.openrouteservice.org/uploads/default/original/1X/7cf4fb2f66336ec9e28fd31c9a902ea2c7e12c6f.png)

Headers = {accept: application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8 Authorization: Bearer key}

RequestMessage:

{Method: POST, RequestUri: ‘[https://api.openrouteservice.org/v2/matrix/driving-car](https://api.openrouteservice.org/v2/matrix/driving-car)’, Version: 1.1, Content: System.Net.Http.StringContent, Headers:  
{  
accept: application/json  
accept: application/geo+json  
accept: application/gpx+xml  
accept: img/png; charset=utf-8  
Authorization: Bearer key  
Content-Type: application/json; charset=utf-8  
Content-Length: 57  
}}

Responce : {StatusCode: 500, ReasonPhrase: ‘Internal Server Error’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:  
{  
Connection: keep-alive  
X-Ratelimit-Limit: 500  
X-Ratelimit-Remaining: 495  
X-Ratelimit-Reset: 1575367946  
Date: Mon, 02 Dec 2019 11:41:25 GMT  
Server: nginx/1.10.3  
Server: (Ubuntu)  
Content-Length: 438  
Content-Type: application/json  
}}

I am using below code:

var baseAddress = new Uri(“[https://api.openrouteservice.org](https://api.openrouteservice.org)”);  
httpClient.DefaultRequestHeaders.Add(“Authorization”, "Bearer " + “xxx”);

using (var contents = new StringContent(“{locations:[[8.609168,49.893230],[8.589405,50.055435]]}”, Encoding.UTF8, “application/json”))  
{  
HttpResponseMessage response = httpClient.PostAsync(“/v2/matrix/driving-car”, contents).Result;  
responseJson = response.Content.ReadAsStringAsync().Result;  
}  
string jsonString = JsonConvert.SerializeObject(responseJson);  
return new JsonResult() { Data = jsonString, JsonRequestBehavior = JsonRequestBehavior.AllowGet };

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [December 2, 2019, 12:10pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/17 "2019-12-02T12:10:58Z")

</div>

I still don’t see any POST parameters… I don’t see how I can help you… It works for everyone else, so I’m pretty sure that’s a basic programming mistake on your side and we can’t fix that for you.

---

<div class="post-metadata">

### Author: ![vamsi](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/v/b38774/32.png) [@vamsi](https://ask.openrouteservice.org/u/vamsi)
#### Post date: [December 3, 2019, 10:12am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/18 "2019-12-03T10:12:14Z")

</div>

Nils,

 ![Error](https://ask.openrouteservice.org/uploads/default/original/1X/1f168069dc9b559e0aa04e4324c5e400d3bec06e.png)

i am passing inputparameters: {coordinates:[[8.609168, 49.893230],[8.589405, 50.055435]]}

httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));  
httpClient.DefaultRequestHeaders.Add(“Authorization”, “Bearer " + “key”);  
var serializedAuthor = JsonConvert.SerializeObject(data);  
var serializedData = serializedAuthor.Replace(@”“”", “”);

```
            using (var content = new StringContent(serializedData, Encoding.UTF8, "application/json"))
            {
                    using (HttpResponseMessage response = await httpClient.PostAsync("/v2/directions/driving-car", content))
                    { 
                      responseData = await response.Content.ReadAsStringAsync();
                    }
                } 
            } 

```

Headers {Accept: application/json Authorization: Bearer key}

RequestMessage {Method: POST, RequestUri: ‘[https://api.openrouteservice.org/v2/directions/driving-car](https://api.openrouteservice.org/v2/directions/driving-car)’, Version: 1.1, Content: System.Net.Http.StringContent, Headers:  
{  
Accept: application/json  
Authorization: Bearer key  
Content-Type: application/json; charset=utf-8  
Content-Length: 59  
}}

Stil i am not getting any responce from server.

my complete code also i mentioned in above screen shorts.

Thanks  
Vamsi

---

<div class="post-metadata">

### Author: ![nils](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/nils/32/6_2.png) [@nils](https://ask.openrouteservice.org/u/nils)
#### Post date: [December 3, 2019, 10:53am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/19 "2019-12-03T10:53:33Z")

</div>

No idea… Please format the code, this is markdown. It’s painful to look at… Unfortunately that’s not only applying to the formatting…

No idea about C#, but this looks wrong: `Content: System.Net.Http.StringContent` as the content for a POST request. Why a string? Compare with

> <https://stackoverflow.com/questions/18924996/logging-request-response-messages-when-using-httpclient/18925296#18925296>

There it’s a `Content: System.Net.Http.ObjectContent`, which makes a whole lot more sense. But like I said, no idea about C#… Please post a question on stack overflow, this is not a an issue with our software, but your code…

---

<div class="post-metadata">

### Author: ![SonGokuOnBike](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@SonGokuOnBike](https://ask.openrouteservice.org/u/SonGokuOnBike)
#### Post date: [February 28, 2020, 12:37am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/20 "2020-02-28T00:37:55Z")

</div>

Hi all, I found a solution, using C# Code:

1. Clear DefaultRequestHeader
2. User Bearer ( not Authorization ) as Key
3. Escape double quotes inside StringContent
4. Add Encoding and MediaType to StringContent constructor

 ![image](https://ask.openrouteservice.org/uploads/default/original/1X/6329a3350e1f68305014eea95a4cc1d5a944fe0d.png)

Hope this helps 🙂

[Next page](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495.md?page=2)
