Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass parameter using Ext.Ajax.request when method type is DELETE

I am trying to send use Ext.Ajax.request method to delete some data on server. My request method looks as below :

Ext.Ajax.request({
      url: '/myserver/restful/service/delete',
      method: 'DELETE',
      headers: {
        'Content-Type': 'application/json'
      },
      params: {
        userId: 12345
      }
});

On my jersey server I have written which looks like as below :

@Path("/delete")
  @DELETE
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response deleteUser(final String userId) {
    System.out.println("user id = " + userId);
    return Response.ok().entity("success").build();
  }

This method prints out user id in following format :

user id = userId=12345

So my expected value for userId is 12345 but it is giving me userId=12345. As I am newbie to jersey thing, I am not able to decide what to do now.

Can anyone please tell what is going wrong?

like image 985
Shekhar Avatar asked Apr 19 '26 21:04

Shekhar


1 Answers

Not sure about what's going wrong in Jersey, but... if you are trying to use DELETE with a request body you're on the wrong track anyway. Don't. The only relevant parameter for DELETE should be the request URI it's being applied to.

like image 158
Julian Reschke Avatar answered Apr 21 '26 18:04

Julian Reschke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!