tags:

views:

221

answers:

1

Hi guys trying to upload a tweet from my application and when I do a webclient Upload data it returns a WebExecption "The remote server returned an error: (417) Expectation Failed.", after looking around the net I see that people had to put a expect100continue to false to get it to work, after looking back at my code I already had the snippiet in my code. Does anyone else know why it's not working?

Here's my code.

        public bool PostTweet(string tweet)
    {
        string aUrl = "http://twitter.com/statuses/update.xml";

        client.Credentials = new NetworkCredential(_username, _password);

        System.Net.ServicePointManager.Expect100Continue = false;

        byte[] tweetBytes = System.Text.Encoding.UTF8.GetBytes("status=" + tweet);

        client.UploadData(aUrl,tweetBytes);

        return true;
    }

Hope this helps, and thanks in advance

A: 

Try to create the WebClient instanse after you change Expect100Continue to false.

DxCK