Skip to content

Status Code 403:Forbidden - Solution #50

Description

@poynty

For the past few months using the default implementations of the clients in this library has resulted in HTTP status codes of 403. The reason is that CoinGecko now require a user agent specified in the requests.

This library already provides the fix built in you just have to use it!

If we look at the BaseAPIClient in the library we see this at line 43:

//_httpClient.DefaultRequestHeaders.Add("User-Agent", "your bot 0.1");

Each client in this library provides the ability to pass in your own instance of System.Net.HttpClient which is great because you can make one and set a DefaultRequestHeader of User-Agent.

So for example:

//Create an instance of System.Net.HttpClient and add our request header
HttpClient hClient = new HttpClient();
hClient.DefaultRequestHeaders.Add("User-Agent","myApp or whatever");

//Pass our HttpClient instance to the CoinCecko client
ICoinGeckoClient cgClient = new CoinGeckoClient(hClient);

Hopefully this helps anyone getting this problem.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions