I am trying as follows:
SSHKEY=`cat ~/.ssh/id_rsa.pub`
curl -u username:password -X POST -H "Content-Type: application/json" -d '{"key": "$SSHKEY", "label": "someLabel"}' https://api.bitbucket.org/2.0/users/username/ssh-keys
But it is giving:
{"type": "error", "error": {"fields": {"key": ["That SSH key is invalid."]}, "message": "key: That SSH key is invalid."}}
Any idea on how to send this ssh key to bitbucket using api?