Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created November 14, 2013 12:50
Show Gist options
  • Select an option

  • Save aslakhellesoy/7466252 to your computer and use it in GitHub Desktop.

Select an option

Save aslakhellesoy/7466252 to your computer and use it in GitHub Desktop.
Can't create a new empty file on GitHub using API
# This works
curl -u USER:PASS https://api.github.com/repos/USER/REPO/contents/a.txt --request PUT --data-ascii $'{"path": "a.txt", "content": "bXkgbmV3IGZpbGUgY29udGVudHM=", "message": "hello"}'
# Does not work
curl -u USER:PASS https://api.github.com/repos/USER/REPO/contents/a.txt --request PUT --data-ascii $'{"path": "a.txt", "content": "", "message": "hello"}'
# HTTP status 422. Body:
# {
# "message": "content is not valid Base64",
# "documentation_url": "http://developer.github.com/v3/repos/contents/"
# }
# However, this creates an empty (0 bytes) file:
echo "" | base64 --decode > tmp.txt && ls -al tmp.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment