gpt4 book ai didi

azure - 远程服务器返回错误: (405) The resource doesn't support specified Http Verb

转载 作者:行者123 更新时间:2023-12-03 01:44:34 25 4
gpt4 key购买 nike

我想更新 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:

Azure Storage APIs for .NET

该 SDK 还实现了指数重试策略来处理暂时性错误(503 - 服务不可用),否则您必须自己实现该策略。

关于azure - 远程服务器返回错误: (405) The resource doesn't support specified Http Verb,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48686591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com