I am trying to post a Twitter status update and I just can't get it to work.
var consumer = new TwitterConsumer(); // WebConsumer implementation var httpClient = new HttpClient(consumer.CreateAuthorizingHandler("THE_TOKEN", new HttpClientHandler())); var content = new FormUrlEncodedContent(new Dictionary<string, string> { {"status", "test"} }); // yes, yes, ugly code, only testing here var s = httpClient.PostAsync("https://api.twitter.com/1.1/statuses/update.json", content); var t = s.Result; var u = t.Content.ReadAsStringAsync().Result; // HTTP 401, response from Twitter is {"errors":[{"message":"Could not authenticate you","code":32}]}
Of course, initially I thought there were some problems with my authentication tokens or the OAuth process, but everything else worked fine:
OAuth authentication seems to work because I can access other API methods like https://api.twitter.com/1.1/account/settings.json .
I can even post status updates when sending status via a URI , such as POST https://api.twitter.com/1.1/statuses/update.json?status=test . I get an error when I try to put status in the request body.
According to Google, many people have similar problems, unfortunately, the proposed solutions (for example, double checking the url encoding or content -Request-Header) do not work for me (the request looks like Fiedler should).
Hannes sachsenhofer
source share