How to send payload data using sitebricks web client using http delete method

245 views
Skip to first unread message

Adio Gemon

unread,
Apr 25, 2013, 4:52:20 AM4/25/13
to google-s...@googlegroups.com

I am using sitebricks http client to send http requests to a rest service. My question is how to send a payload data with delete ? post method accepts data as a parameter

WebClient<SubnetId> client = web().clientOf(deleteUser()).transports(User.class).over(Json.class);

//client.post(user) <-- this is OK ! 

client.delete(); // <-- delete does not accepts user !!!

Dhanji R. Prasanna

unread,
Apr 25, 2013, 5:17:13 AM4/25/13
to google-s...@googlegroups.com
The http delete method does not support a body, so you should use the URI to pass whatever additional info you want either as query params or matrix params
--
You received this message because you are subscribed to the Google Groups "Google Sitebricks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-sitebri...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Adio Gemon

unread,
Apr 25, 2013, 7:06:10 AM4/25/13
to google-s...@googlegroups.com
Dihanji, thanks for the quick reply. 

I wonder why delete does not support a body ? Using AngularJS I am able to support DELETE method body just perfectly. 

Dhanji R. Prasanna

unread,
Apr 25, 2013, 8:47:47 AM4/25/13
to google-s...@googlegroups.com
Im not sure but afaik it's not part of the HTTP specification, so it would be a odd that angular allows it (does it also let GET send a body??). 

The idea is that DELETE erases a resource already on the server, identified by the called URI. 

There is some discussion here:

"if the request method does not include defined semantics for an entity-body, then the message-body SHOULD be ignored when handling the request."

The spec does not talk about it at all. But I tend to be puzzled by what body goes thru in a delete. It seems more like GET to me. Or more like PUT(null) if we were to look at it that way. =)

Is there a strong need for it?



--

Adio Gemon

unread,
Apr 26, 2013, 2:24:25 AM4/26/13
to google-s...@googlegroups.com

It is hard to say strong need. The body of delete may represent an ID object of what we want to delete, 
something Like :  

  @Post
  public Reply deleteUser(Request request) {
    UserId id = request.read(UserId.class).as(Json.class);
    service.deleteUser(id);
    return Reply.saying().ok();
  }

On Thursday, 25 April 2013 11:52:20 UTC+3, Adio Gemon wrote:
Reply all
Reply to author
Forward
0 new messages