Michael
Michael

Reputation: 11

POST with API in C#

I'm trying to POST data via an API but i'm getting an error 420 'Enhance your calm'.

If there is something i'm doing wrong ? (if you have another method in C# to POST in an API always welcome to share your solution )

Thank you

        try {
            HttpClient client2 = new HttpClient();
            client2.BaseAddress = new Uri("https://kbhb-officialpayments-test.sportlink-interfaces.net/entity/kbhb/officialpayments/UnionOfficialOfficialAssignment");
            client2.DefaultRequestHeaders.Add("Authorization", "Bearer aaafdsqgfdsgfdsgfzq");
            client2.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));//ACCEPT header

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "");
            request.Content = new StringContent("{\"PersonId\":\""+ personID + "\",\"FunctionId\":\"" + functionID + "\",\"ExternalMatchId\":\"" + matchID + "\",\"DistrictId\":\"" + district + "\"}", Encoding.UTF8, "application/json");//CONTENT-TYPE header

            client2.SendAsync(request)
                  .ContinueWith(responseTask => {
                      Console.WriteLine("Response: {0}", responseTask.Result);
                  });
        } catch (Exception ex) {
            Console.WriteLine(ex.Message);
        }

Upvotes: 0

Views: 128

Answers (3)

joe11093
joe11093

Reputation: 418

The 420 Enhance Your Calm status code means that you are being rate limited. It's similar to 429: Too many Requests. This means you are sending what they consider to be too many requests, too quickly.

Upvotes: 0

nvoigt
nvoigt

Reputation: 77294

If there is something i'm doing wrong ?

420 is the code you get from the server. It's not official, so you'd have to ask the server provider what it means and what you should do.

Normally, 420 is another way to say you are rate limited (so actually status code 429). You sent too many requests over a short timeframe, so the service is blocking you. Again, whether that is the case, what constitutes "too many" or "timeframe" in their implementation is specific to their implementation and is something we cannot say. Contact them and ask.

Upvotes: 2

Dishonered
Dishonered

Reputation: 8841

It seems you are being limited.

The status code 420 : Not part of the HTTP standard, but introduced by Twitter. This was used by Version 1 of their API when requests from a particular client were being rate limited.

Upvotes: 0

Related Questions