Once you intend to perform a GET
request, you could send data in the query string using one of the following approaches:
curl -G http://example.org -d "query=1,2,3"
curl -G http://example.org -d "query=1&query=2&query=3"
Let me highlight that payloads in GET
requests are not recommended. Quoting the RFC 7231:
A payload within a GET
request message has no defined semantics; sending a payload body on a GET
request might cause some existing implementations to reject the request.
Also bear in mind that GET
requests shouldn't be used to modify resources: they are intended to be used for information retrieval only, without side effects. Having said that, GET
is both safe and idempotent. You can see more details on these concepts in this answer.
If the data must be sent in the payload (and you intend to modify the resource) then stick to POST
. Assuming your payload is a JSON document, you would have something like:
curl -X POST http://example.org \
-H "Content-Type: application/json" \
-d '["1", "2", "3"]'