401 on C# while all is working fine with SOAPUI


Hi everyone,

I’m running through an issue for all the day and I’m starting to cry…

So, what’s happening ?

I’m trying to take the very last tweet of a twitter user with c# and I thought I was doing everything well but it seems that I had forgot something.

With my API keys (basic and secret), I have made a request to generate my acces_token. Then, I try to call the API with that token and I receive a 401:Unauthorized (nothing more).

While trying my request in SOAP UI, I have my tweet… I don’t know what to do…

So, there is my code.

HttpWebRequest twitterStatusRequest = (HttpWebRequest)WebRequest.Create("https://api.twitter.com/1.1/statuses/user_timeline.json?user_id=mickaelquitweet");
twitterStatusRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

twitterStatusRequest.Method = "GET";
twitterStatusRequest.Headers[HttpRequestHeader.Authorization] = twitterAccess_token_Type + " " + twitterAccess_token;
twitterStatusRequest.UserAgent = "MY APP";
HttpWebResponse twitterStatusResponse = null;
    twitterStatusResponse = (HttpWebResponse)twitterStatusRequest.GetResponse();

And here I get the Whaaaaat 401

If you all have an idea of what happens here, I would be very gratefull.

See you all, and thanks for all!!!