Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error HTTP/1.0 405 Method not Allowed

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

like image 908
Rozy Avatar asked Feb 05 '11 03:02

Rozy


People also ask

Why am I getting a 405?

A 405 Method Not Allowed Error is an HTTP response status code that indicates a web browser has requested access to one of your web pages and your web server received and recognized its HTTP method.

What does Method Not Allowed mean?

The 405 Method Not Allowed error is an HTTP response status that tells you that a web browser has made a request to access one of your website's pages. Your web server has received the request and recognized it but has rejected the specific HTTP method that was used.

How do I fix 405 Method not allowed in Postman?

If you are certain you need a POST request, chances are, you're just using the wrong endpoint on the server. Again, this can only be solved if you have proper documentation to show what methods are supported for each endpoint.


2 Answers

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

like image 80
Steven Benitez Avatar answered Oct 15 '22 22:10

Steven Benitez


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.

like image 45
Matti Virkkunen Avatar answered Oct 15 '22 20:10

Matti Virkkunen