2016-07-28 89 views
0

我正在使用azure移動服務,我發送帶請求的身份驗證令牌。獲取請求正在從客戶端工作,但是當我嘗試點擊POST請求時,它拋出異常「遠程服務器返回錯誤:(405)方法不允許。」事件我綁定身份驗證令牌與請求。這裏是我的代碼: -Azure移動服務,遠程服務器返回錯誤:(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; 
>     } 

如果任何人有任何想法,請與我分享。我已經嘗試了與郵差相同的請求,這是工作。我用於「獲取」請求的方式也是如此。

+0

這裏很難說清楚細節 - 您發佈的URL最爲有用!服務器已被配置爲返回405 - 可能是因爲您的表格不允許使用該方法,或者您的自定義API沒有定義後期功能。 –

+0

由於不使用Azure移動客戶端SDK,您的工作變得更加困難。您是否有直接進行REST呼叫的特定原因?有關客戶端SDK的信息,請參閱https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-xamarin-forms-get-started/和https://azure.microsoft.com/EN-US /文檔/文章/應用服務,移動DOTNET - 如何使用的客戶端庫/ –

回答

0

這意味着,服務器不支持POST請求該網址。也許你需要GETPUT。與認證沒有任何關係。

相關問題