I make a GET call to an API in my bash script, which lets me specify an array of query parameters (e.g. items
). So far I have successfully used curl as follows:
curl "https://my-fancy-api.com/api/query-items?items=abc1&items=def2&items=ghi3" -H "Accept: application/json" -H "Authorization: Bearer ${SOME_TOKEN}"
This outputs some JSON which I continue to process. So far, all works out well, as I only pass three query parameter items for the items
parameters.
Now my problem: I want to scale this up and process a large amount of items at once. I am talking ~500.000 items which I would need to specify as query parameters, and unfortunately the API does not provide any other method of handing over items. So I am stuck with a curl call that contains about 500k variants of &items=foo
.
While the creation of the curl command is no problem, the size now causes the (expectable) failure
/usr/bin/curl: Argument list too long
I am looking for either a way to circumvent this problem with curl, or an easy tool that comes preinstalled on Ubuntu to switch to.
Should there be nothing really, I would also consider breaking this up into batches. Any suggestion how to achieve any of these without too much overhead?