0

I am able to POST data with curl in the JSON format with the loop in bash script

Current
$(curl -o /dev/null -s  -X POST “${url}" -H "accept: application/json" -H "Authorization: ${base}” -H "Content-Type: application/json" -d “{\”data1\”:\”${data1}\”,\”data2\”:\”${data2}\”}”)

[
   {
     "data1": "data1",
     "data2”: "data2”
   },
   {
    "data3”: "data3”,
     "data4”: "data4”
    }
]

But my requirement is to achieve below format in JSON array with curl. Please help me to achieve me to append JSON with curl command with every iteration of loop.

{“Array":  [
    {
      "data1": "data1",
      "data2”: "data2”
    },
   {
      "data3”: "data3”,
      "data4”: "data4”
    }
]
}
3
  • stackoverflow.com/questions/15425446/… Commented Mar 3, 2020 at 15:24
  • What are the curly quotes doing in there? This can never work -> “{\”data1\”:\”${ Commented Mar 3, 2020 at 15:24
  • This is the way it works when we want to POST in JSON with curl and it is working for me too. Commented Mar 3, 2020 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.