GitHub API v3 failing to post Deploy Keys

Working on a Bash script to automate Deploy Key rotations, and I am regularly getting a Unicorn! · GitHub response.  Here is the command I am running:


function push_ssh_key() {

  local KEY_CONTENT="$(cat /root/.ssh/id_rsa_${1}_${DATE}.pub)"

  local JSON="{“title”: “${1}_${DATE}”, “key”: “${KEY_CONTENT}”, “read_only”: true}"

  curl \

    --header “Authorization: token <my_access_token>” \

    --header “Accept: application/vnd.github.v3+json” &nbsp; # application/json also fails

    --request POST \

    --data “$JSON” \

    “https://api-github.com/repos/my_account/${1}/keys

}

DATE is set globally for other functions to reference

push_ssh_key “repository_a”


I can verify that the JSON I am passing to the URL is proper JSON:

{“title”: “repository_a_2018-12-31”, “key”: “ssh-rsa AAAAB3Nz… me@email.com”, “read_only”: true}

As far as I can tell, I am following everything according to the docs

https://developer.github.com/v3/repos/keys/

What am I missing?  

Hey @daytonpa,

Thank you for being here! Could you please send us the full output of a curl -v request that demonstrates the problem?

http://curl.haxx.se/

That should help us investigate the issue. Also, please make sure you mask any sensitive information like OAuth tokens and Authorization headers in the output of the curl command. Please send the output to https://github.com/contact. And include a link to this thread to give support some background on the ticket.

I hope this helps!

Best,
Andrea

Hi @daytonpa,

When you say that you are regularly getting a unicorn response, does that mean that you are getting a unicorn response every time or just a large part of the time? Do you ever get a different response?

Thanks!