I want to create a Gist containing a JSON (valid one, I checked) with curl
command as described here.
I tried first this script :
configText=$(cat jsonFile.json)
generate_post_data()
{
cat <<EOF
{
"description": "the description for this gist",
"public": true,
"files": {
"file1.txt": {
"content": $configText
}
}
}
EOF
}
curlBody="$(generate_post_data)"
curlResponse=$(curl -H "Content-Type: application/json" -X POST -d '$curlBody' https://api.github.com/gists)
Which gave me the error Problems parsing JSON
, so I tried passing the file directly in the command:
curl -H "Content-Type:application/json" -data-binary @jsonFile.json https://api.github.com/gists
But I'm getting the same error. I know that this must be a conflict between the JSON body of the POST request and the JSON of my file (quotes, brackets...).
How can I send a clean JSON file to Gist ?