作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想更新 Azure 上 Blob 存储中的 json 文件,而 WebClient.uploadData(url,data)
它给出错误:
The remote server returned an error: (405) The resource doesn't support specified Http Verb..
代码是这样的:
[Route("PostJsonData")]
[HttpPost]
public void PostJSONData(string value)
{
try
{
string url = @"https://apkupdates.blob.core.windows.net/polaadapk/keywords.json";
byte[] json1 = new WebClient().DownloadData(url);
string result = System.Text.Encoding.UTF8.GetString(json1);
byte[] array = System.Text.Encoding.ASCII.GetBytes(value);
WebClient myWebClient = new WebClient();
Stream postStream = myWebClient.OpenWrite(url, "POST");
postStream.Write(array, 0, array.Length);
myWebClient.UploadData(url, array);
postStream.Close();
}
catch (Exception ex)
{
throw ex;
}
}
最佳答案
正如 Gaurav 已经提到的,您使用了错误的动词。不过,我强烈建议使用现有的 .NET SDK:
该 SDK 还实现了指数重试策略来处理暂时性错误(503 - 服务不可用),否则您必须自己实现该策略。
关于azure - 远程服务器返回错误: (405) The resource doesn't support specified Http Verb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48686591/
我是一名优秀的程序员,十分优秀!