Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

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

$
0
0

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

Viewing all articles
Browse latest Browse all 148

Trending Articles