Skip to main content
1 of 4
rSh
  • 11
  • 1
  • 3

POST json data with cURL from a while loop - bash shell

I have a JSON output from which I need to extract an ID and Iterate through them and send multiple request to API execute REST API with curl. For example:

This is how the JSON output looks like:

{ "glossary": [ { “Title“: "example glossary1”, “id”: 1, "description": “Hello Glossary1“ }, { “Title“: "example glossary2”, “id”: 2, "description": “Hello Glossary2“ }, { “Title“: "example glossary3”, “id”: 3, "description": “Hello Glossary3“ }, { “Title“: "example glossary4”, “id”: 4, "description": “Hello Glossary4“ }

] }

The shell script should loop through this JSON file, extract the ID and loop through and execute REST API calls with CURL.

Here is example:

for (( i = 0 ; i < ${#id[@]} ; i++ )) do POST REST API done

Can anyone help with this?

rSh
  • 11
  • 1
  • 3