Page 1 of 1

Best practice for RESTful web services POST.

PostPosted: Thu Sep 24, 2015 1:59 pm
by AlanBourke
Imagine I am implementing a RESTful web service with Servoy which will add customer records to the database. I might want to send in 10 or 20 new customers in a run.


In terms of how Servoy implements these (headless client etc.) is it:

(a) More efficient to send in all 20 at once, i.e. have the web service deserialise and process the 20, but then have to implement some way of informing the caller as to which failed (if any).
(b) More efficient to send them in one at a time, and process the response for each, and let Servoy's pooling and resource management handle the repeated calls.
(c) it doesn't really matter either way in terms of efficiency on the Servoy side.

Thanks

Re: Best practice for RESTful web services POST.

PostPosted: Thu Sep 24, 2015 2:54 pm
by mboegem
Hi Allen,

Setting up 1 request/connection with more data would be more efficient, if only it was for processing multiple records into a foundset and calling databaseManager.saveData() just once...

As for the part of returning the result:
https://wiki.servoy.com/display/DOCS/RESTful+Web+Services#RESTfulWebServices-SupportingPOSTRequests

The method can optionally return a JavaScript primitive/array/object or a byte array.
If the return value is a JavaScript object, it will be serialized and then placed in the body of the HTTP Response. See Returning Binary Data for more info on returning binary content.


Hope this helps

Re: Best practice for RESTful web services POST.

PostPosted: Thu Sep 24, 2015 3:05 pm
by AlanBourke
That's what I felt, thanks.