Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting error 405 Method Not Allowed when calling a @GET webservice using a post method.  RSS feed

 
Adi Ishi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we call a webservice method which uses @GET in another resful service using POST method.

I'm calling the methods in ServiceRestful.java, the method looks like this
 
Stephan van Hulst
Saloon Keeper
Posts: 7927
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So then why are you calling exchange() with HttpMethod.POST?
 
Adi Ishi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did tried like this, I still get the same error

String response = restTemplate.postForObject(paycardIdPath, request, String.class);
return response;
 
Ron McLeod
Bartender
Posts: 1602
232
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using a POST request targeted for a handler method which is annotated indicating that it handles GET requests -- 405 Method Not Allowed seems like a proper response.
 
Stephan van Hulst
Saloon Keeper
Posts: 7927
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, it should be possible to forward the request to a GET action, but then pass the GET verb!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!