2

when sending http delete to my server this happens

Response Status: 405 (Method Not Allowed)

header look like this

Date: Sat, 31 Jan 2015 19:17:47 GMT
Server: WildFly/8
Connection: keep-alive
X-Powered-By: Undertow/1
Content-Length: 0
Allow: HEAD, POST, GET, OPTIONS, PUT

I suspect that I have to enable access to http delete method, but don't know how.

this is my delete method

@DELETE
@Path("/{id}")
public boolean deleteItem(@PathParam("id") long itemId);

this is the url for delete

wrong: http://192.168.2.101:8080/DataAccessRemoteWebapp/rest/dataitem/id=1

right: http://192.168.2.101:8080/DataAccessRemoteWebapp/rest/dataitem/1

I am using jax-rs

import javax.ws.rs.DELETE;
Visores
  • 4,008
  • 4
  • 18
  • 29
  • oh yeah you right >. – Visores Feb 01 '15 at 01:59
  • Yes partly, with this I could test my delete method and I found out the method was wrong, so yeah Thx :D – Visores Feb 01 '15 at 09:40
  • 1
    Welcome. On a matter of Stack Overflow policy, rather than editing the answer into the question, it's better to post it as an answer. If someone with the same issue finds your question in a search, it won't be obvious that your "right:" in the question is the solution to the original question, unless they read the comments (which they shouldn't have to do). It's fine to post and accept an answer to your own question (or if someone solved it for you in a comment you could suggest they post it as an answer, which I'll do now). I suggest you revert your question edit in order to make it clearer. – CupawnTae Feb 01 '15 at 17:31

2 Answers2

4

The annotation @Path("/{id})" requires the id directly after the / and so it won't match your test URL

http://192.168.2.101:8080/DataAccessRemoteWebapp/rest/dataitem/id=1

Instead, remove the id=:

http://192.168.2.101:8080/DataAccessRemoteWebapp/rest/dataitem/1
CupawnTae
  • 14,192
  • 3
  • 29
  • 60
1

This old post on stackoverflow can respond to you question :

URL = /contacts/delete/contactname

405 because

It seems delete is always behave as submit (Post method) and you are trying >to call as like get method from the URL. This is not possible to call the >post method as like get. if you really want to call this web service from >the browser to test, just download a Mozilla plugin (Poster) which will help >you to submit the web service in your all method types.

Community
  • 1
  • 1
Karim BENHDECH
  • 371
  • 2
  • 9