curl -usigmavirus24 -v -H "Content-Type: application/json" -X POST -d '{"name": "cia", "active": true, "events": ["push"], "config": {"url": "...", "content_type": "json"}}' https://api.github.com/repos/sigmavirus24/reponame/hooks
Is the correct curl command. The URL you're posting to has to be https://api.github.com/:endpoint
where :endpoint
in this case is repos/username/reponame/hooks
. You also need to use '
s around the JSON body for the curl command because otherwise you'll get strings like "{ "
concatenated with the output of commands like name
, cia
, active
, events
, etc.
Also the -u :username
option is necessary for curl so it will tell curl that it MUST authenticate and ask you for the password to do so.
If you don't mind your password being in your bash history (WHICH YOU SHOULD) you can also do -u username:password
. Or even better you can base64 encode your credentials in the form username:password
and then send that as a header like so: Authentication: Basic <base64-encoded-credentials
.