1

I am trying to use GitHub API to create an issue, by

curl -u $username  -d '{"title" : "Big Files List" , "body" : "'$(find -type f -size +1M)'", "label" : "big files" } $URL -k'

however, I got the response like

curl: (3) [globbing] unmatched close brace/bracket at pos 56
{
"message": "Invalid request.\n\nFor 'links/0/schema', \"body\" is not an 
object.",
"documentation_url": 
"https://developer.github.com/enterprise/2.15/v3/issues/#create-an-issue"
}

So the issue is within $(find -type f -size +1M) , when I replace is with string, there is not issue.

  • `find` is returning multiple filenames, so the `-d` argument is being split into multiple arguments. – Barmar Dec 24 '18 at 21:41

1 Answers1

1

curl is returning multiple filenames, and the whitespace after the first filename is ending the -d argument, so you're sending incomplete JSON. You need to quote it so it's not split up.

But that's not enough, because literal newlines also aren't allowed in JSON. You need to translate the newlines to \n.

You also had the closing quote in the wrong place, it should be at the end of the JSON, not the end of the line.

bigfiles=$(find -type f -size +1M)
bigfiles=${bigfiles// /\\n}
curl -u $username  -d '{"title" : "Big Files List" , "body" : "'"$bigfiles"'", "label" : "big files" }' $URL -k
Barmar
  • 741,623
  • 53
  • 500
  • 612