Trying to do my first tweet from c#, wpf application


I’m new to Twitter API. Using .net c# on WPF platform. I have created an application and already obtained my accesstoken and accesstoken secret for read/write permissions. When I do the following request.GetResponse() returns with unauthorized Exception.
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(resource_url);
request.Headers.Add(“Authorization”, authHeader);
request.Method = “POST”;
request.ContentType = “application/x-www-form-urlencoded”;
using (Stream stream = request.GetRequestStream())
byte[] content = ASCIIEncoding.ASCII.GetBytes(postBody);
stream.Write(content, 0, content.Length);
WebResponse response = request.GetResponse();

I have gone through the OAuth steps in getting a signature, encrypting it, and creating the authHeader. At this point, I’m not sure if the problem is a bad header or I simply don’t have permissions to tweet to my account. Note that I am simply trying to tweet to my own account (not someone elses), so I have the username and password info.



There are different reasons for the 401 and here’s a FAQ that might help:

Generally, you’ll want to dig into the exception message to see the reason that Twitter gives you. If that doesn’t help, you should get Fiddler2 and look at the HTTP traffic to get more information on the response. You might also want to look at some code that works and compare the HTTP message it produces, as well as the code, and compare that to what you’re creating. You can look at the LINQ to Twitter source code ( or check out some of the other open source libraries that do the same thing.