Note that there are some explanatory texts on larger screens.

plurals
  1. PORESTful Spring service with multiple parameters
    primarykey
    data
    text
    <p>I'm constructing a restful service which needs to accept <em>any</em> number of parameters instead of the <em>one</em> from the sample below. </p> <p>Assuming the following service routine</p> <pre><code>@RequestMapping("/start/id/{id}", RequestMethod.GET) public void startService(@PathVariable String id) {...} </code></pre> <p>there's a client implementation based on <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="nofollow noreferrer"><code>RestTemplate</code></a></p> <pre><code>restTemplate.getForObject("/start/id/{id}", null, id); </code></pre> <p><strong>Question:</strong> But given that it might be thousands of <code>ids</code>, what restful approaches do I have to sending all parameters in one request using <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="nofollow noreferrer"><code>RestTemplate</code></a>? I've seen the suggestions</p> <ul> <li>Add request body to GET request - Doesn't seem possible with <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="nofollow noreferrer"><code>RestTemplate</code></a>?</li> <li>Use a separator in id, (e.g., <code>id1|id2|....|idn</code>) - Seems like a <em>hack</em></li> <li>PUT the parameters first, then issue a GET to reference the ids - Double requests, seems non-intuitive</li> <li>Adding multiple URL parameters (<code>?id=foo&amp;id=bar&amp;.....&amp;id=foobar</code>)</li> </ul> <hr> <p>I know similar questions (<a href="https://stackoverflow.com/questions/3841708/calling-a-restful-service-with-many-parameters">calling-a-restful-service-with-many-parameters</a>, <a href="https://stackoverflow.com/questions/1619152/how-to-create-rest-urls-without-verbs">how-to-create-rest-urls-without-verbs</a>, <a href="https://stackoverflow.com/questions/5377732/can-you-build-a-truly-restful-service-that-takes-many-parameters">can-you-build-a-truly-restful-service-that-takes-many-parameters</a>) has been asked before but I found it hard to spot a satisfactory answer, or at least an answer based on <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/client/RestTemplate.html" rel="nofollow noreferrer"><code>RestTemplate</code></a>. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload