【问题标题】:How to use PUT method in WP8 using WebClient() [closed]如何使用 WebClient() 在 WP8 中使用 PUT 方法 [关闭]
【发布时间】:2013-12-07 10:50:31
【问题描述】:

我能够使用 Webclient 获取和发布数据,但我需要知道如何将数据放入/更新到服务器中。..

我在 WebClient 中尝试使用 PUT 方法的代码..

string serviceURL = REST_URI + servicePath;
Uri URI = new Uri(serviceURL);
WebClient webClient = new WebClient();
webClient.Headers["ContentType"] = "application/json";
webClient.Headers["Accept"] = "application/json";
webClient.UploadStringCompleted += this.updationCompleted;
webClient.UploadStringAsync(URI, "PUT", organizationDetails);



private void updationCompleted(object sender, UploadStringCompletedEventArgs e)
{
    try
    {
        MessageBox.Show("Success..");
        MessageBox.Show(e.Result);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);//i'm getting error here as check for inner exception..
    }

我的例外..

谁能帮我解决这个问题

我的内部异常消息..

【问题讨论】:

  • 异常说明了什么?
  • 查看我更新的帖子..
  • 也发布您的 InnerException。
  • 对不起,我不知道如何找回它。我是 WP8 新手
  • @farokemoahmed 只需在 catch 中放置一个断点并检查 ex.InnerException 中的内容

标签: c# .net windows-phone-8 webclient put


【解决方案1】:

这不是你的问题:

The remote server returned an error: NotFound.

服务器端似乎没有这样的可用方法,或者它不接受PUT

确保您使用正确的 uri、http 动词和内容类型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-24
    • 2013-09-07
    • 2021-07-29
    • 1970-01-01
    相关资源
    最近更新 更多