This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi, first of all sorry if this isn't the appropiated thread to post my problem but i think if my problem is about http request this could be the right thread.
I have developed RESTful web services, to consume this service you do via HTTP requests, that can be GET, POST, PUT, DELETE and so on, mapped to methods defined in web service. Now i'm developing a simple java application to consume this services. I've found that i can use the object HttpURLConnection to do HTTP requests and specify the method that i wanna use, in my case i want to do a POST request. The code of my application is this:
Is a simple java application without gui. When i run it, i get this message:
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 405 for URL: ....
I can't understand why it doesn't admit the request even when i specify the protocol.
Wanna grow? Learn, live, love people and enjoy life
You might be trying to call the post method.. on a "GET" resource.
Joined: Nov 27, 2009
Well, i couldn't read the forum because a problem, but in reply to you Chinna Eranna, my RESTful Web service has a POST resource, i've checked it. I tested my application consuming a GET resource and i have no problem, the application consumes the resource very well, but when i change the resource to POST and my application specifying the POST protocol, it fails.
I don't know if this is important, but here's my RESTful web service:
The GET resource that is commented works very well, while POST resource can't be consumed from my java application.