簡體   English   中英

Azure移動服務,遠程服務器返回錯誤:(405)不允許的方法

[英]Azure mobile service, The remote server returned an error: (405) Method Not Allowed

我正在使用azure移動服務,正在發送帶有請求的身份驗證令牌。 從客戶端獲取請求正在工作,但是當我嘗試執行POST請求時,它會引發異常“遠程服務器返回錯誤:(405)不允許的方法。” 事件我將身份驗證令牌與請求綁定。 這是我的代碼:

>      string result = string.Empty;
>                 request.ContentType = "application/json";
>                 request.Method = "POST";
>     
>                 if (!string.IsNullOrEmpty(requestData))
>                 {
>                     UTF8Encoding encoder = new UTF8Encoding();
>                     byte[] data = encoder.GetBytes(requestData);
>                     Task.Factory.FromAsync<System.IO.Stream>(request.BeginGetRequestStream,
> request.EndGetRequestStream, null).Result.Write(data, 0, data.Length);
>                 }
>     
>                 request.Headers["x-zumo-auth"] = auth_token;
>                 request.Headers["ZUMO-API-VERSION"] = "2.0.0";
>                 try
>                 {
>     
>                 
>                 WebResponse webResponse = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse,
> request.EndGetResponse, null).Result;
>                 using (var streamReader = new StreamReader(webResponse.GetResponseStream()))
>                 {
>                     result = streamReader.ReadToEnd();
>                 }
>                 }
>                 catch (Exception ex)
>                 {
>     
>                     throw;
>                 }

如果有人有任何想法,請與我分享。 我已經嘗試過與郵遞員相同的請求,這是可行的。 我用於“獲取”請求的方式相同。

這意味着服務器不支持對該URL的POST請求。 也許您需要GETPUT 與身份驗證無關。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM