开发者

Webclient UploadData returns error 417 even after putting expect100Continue to false

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开发者_StackOverflow?

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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜