1
我試圖發佈以休息。httpClient.PostAsync返回「方法不允許」(在winform應用程序中運行)
這是我的代碼:
string URL = "http://xxx.xxx.x.xx:8080/Name/NAME/";
string urlParameters = "?key=T_PAPPS&value=sofsof";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(URL);
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
HttpResponseMessage response = client.PostAsync(URL, new StringContent(urlParameters)).Result;
我的應用程序是WinForm應用程序(而不是web)。
我在做什麼錯?
感謝您的提前。
(restsharp返回同樣的錯誤(在那裏我也沒有成功更改爲應用程序/應用程序/ JSON)的X WWW的形式,進行了urlencoded)
那麼可能它不接受POST請求。 –