# 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:** 3
**Page:** 2

<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: [February 28, 2020, 10:34am UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/21 "2020-02-28T10:34:57Z")

</div>

Hi @SonGokuOnBike,  
Thanks for the working example.  
I will adjust the C# example in the API Playground with this.

If you want to paste code please use

````
```
using {var
...
}
```

````

or the `preformatted text` button.  
then it can be copied 😉

Best regards

---

<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:23pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/22 "2020-02-28T12:23:27Z")

</div>

Hi @amandus,

hope this looks better as example code 🙂

```
private async void buttonTestOpenRouteService_ClickAsync(object sender, EventArgs e)
{
    //Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
    System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
    //Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
    var baseAddress = new Uri("https://api.openrouteservice.org");

    using (var httpClient = new HttpClient { BaseAddress = baseAddress })
    {
        httpClient.DefaultRequestHeaders.Clear();
        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("accept", "application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8");
        httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
        httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "5b3 .. c5");

        using (var content = new StringContent("{\"coordinates\":[[8.678,49.551],[8.502,49.531]],\"attributes\":[\"avgspeed\",\"percentage\",\"detourfactor\"],\"elevation\":\"true\",\"extra_info\":[\"suitability\",\"surface\",\"waycategory\",\"waytype\",\"traildifficulty\",\"osmid\",\"countryinfo\"],\"instructions_format\":\"html\",\"language\":\"de\",\"preference\":\"recommended\"}", Encoding.UTF8, "application/json"))
        {
            using (var response = await httpClient.PostAsync("/v2/directions/cycling-regular/json", content))
            {
                string responseData = await response.Content.ReadAsStringAsync();

                var data = JsonConvert.DeserializeObject(responseData);
            }
        }
    }
}

```

And inside the designer ( it’s a winforms application):

`this.buttonTestOpenRouteService.Click += new System.EventHandler(this.buttonTestOpenRouteService_ClickAsync);`

Best regards

SonGokuOnBike

---

<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: [April 25, 2020, 4:08pm UTC](https://ask.openrouteservice.org/t/403-forbidden-daily-quota-reached-or-api-key-unauthorized/495/23 "2020-04-25T16:08:06Z")

</div>

@SonGokuOnBike,

Some update on the template: I did add some of your changes, but the escaping of the backslashes sadly didn’t work. I added a comment, to escape quotes.

In a bit more detail: We use a highlighting plugin for the different code templates for readability. Before the template is passed, the quotes actually are escaped. But after beautifying it, escaped quotes are replaced by normal ones 😕 There is a setting to disable this which had no effect.

To further look into this is not really worth the outcome right now.  
I know it should be a one click running template, but it has to stay like this for now.

We are using the [vue-markdown](https://www.npmjs.com/package/vue-markdown) component to render the templates and [PrismJS](https://prismjs.com/) for highlighting if someone wants to investigate this.

Best regards

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