RestService and RestTemplate

My Spiring  RestService delete method has signature :

public ResponseEntity<?> delete(@RequestBody List<Long> IdList)

Question :
I am making a client code and trying to send  list of  long id's to  my above service  with the help of  RestTemplate  delete .  But it seems RestTemplate delete method does not accept list of long ids . How to fix this ?

Here is the client code:

RestTemplate.delete("/bsi/extgd/v1" + [2,3,4]);  //  this does not work... as I cant send list of long ids here

Is there any way to send   list of long ids to delete method  ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cofactorAuthor Commented:
any comments ?
mccarlIT Business Systems Analyst / Software DeveloperCommented:
But it seems RestTemplate delete method does not accept list of long ids

This is because the HTTP DELETE method is generally not used with a request body at all, and so RestTemplate has no methods for passing any body content.

So the options are to just hack together a solution. It's probably easier but is less "RESTful" (that may or may not be important to you). Or if you are trying to adhere to the REST ideals, I would go with the idea of creating a new resource (i.e. with a POST call), and the resource is actually a list (or selection) of other resources. The server creates this list and then returns a generated id for this new list resource. Then you can DELETE this resource and it will delete the resources specified in the list. The source of the idea and other useful info is here.
cofactorAuthor Commented:
got some workaround to this . ,,may be useful to others .

solution is :

HttpEntity <Long> httpEntity = new HttpEntity <Long> (Id , header);
Object, HttpMethod.DELETE, httpEntity,new ParameterizedTypeReference<String>() {});

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cofactorAuthor Commented:
there was issue in adding correct data type which I rectified.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.