Error HTTP/1.0 405 Method not Allowed

て烟熏妆下的殇ゞ 提交于 2019-12-10 02:52:37

问题


I want to make an Htttp Connection Here is my code

try
{
HttpClient client = new DefaultHttpClient();
HttpPost httpMethod = new HttpPost("http://www.google.co.in/");
String requestBody = "some text";
HttpMethod.setEntity(new StringEntity(requestBody));
HttpResponse response = client.execute(httpMethod);
textView.setText(response.getStatusLine().toString());
}

But i m unable to and get the "HTTP/1.0 405 Method not Allowed" error I will be thankfull your help


回答1:


It means that the requested URL does not accept the POST method. Try again with GET.




回答2:


Perhaps you should try with a server that accepts POST requests. There's probably nothing wrong with your code, Google's front page just doesn't do POST.

One quick example of a server you could use I can think of is JSFiddle's echo feature. I'm sure they won't mind.



来源:https://stackoverflow.com/questions/4904842/error-http-1-0-405-method-not-allowed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!