vendredi 18 septembre 2015

Is there a standard way in Spring to pass a body with a DELETE request to a REST endpoint?

I am implementing a Spring client for an existing REST API and I need to invoke a DELETE while, at the same time, passing an access token in the request body, like this:

{ 
    "access_token": "..."
}

The problem is that, using the method that works for POST, the transmitted body is empty (I have intercepted the request body and made sure) and I cannot be authorised without this access token. This is what I am doing:

 RestTemplate restTemplate = new RestTemplate();
 UserRequest ur = new UserRequest(access_token);
 HttpEntity<UserRequest> entity = new HttpEntity<>(ur);                                               
 restTemplate.delete(url, entity);

I have no control over the API itself, so I don't have the option of passing the token as url parameter.

Is there a way to do this in Spring, or do I have to build my own HttpUrlConnection like described for instance in this SO answer?



from Newest questions tagged java - Stack Overflow http://ift.tt/1MuMyyx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire