Hi,
I’d like to upload an SSH private key using the REST API. My goal is to translate this CLI command:
travis sshkey --token my_token --upload /tmp/github_deploy_key -r repo/ddddd-e2e-1 -d github
which works for me from the CLI, into a Python script.
I’m using this Python snippet, but I’m getting a 404 Not Found error, with the cause “resource not found”:
encoded_ssh_key = base64.b64encode(private_key).decode(“utf-8”)
repo_slug = “my/ddddd-e2e-1”
headers = {
“Travis-API-Version”: “3”,
“Authorization”: f"token {TRAVIS_API_TOKEN}",
“Accept”: “application/vnd.travis-ci.2+json”,
“Content-Type”: “application/json”
}
url = f"https://api.travis-ci.com/repo/{repo_slug.replace(‘/’, ‘%2F’)}/ssh_key"
payload = {
“description”: “github”,
“value”: encoded_ssh_key,
“public_key”: False
}
response = requests.put(url, headers=headers, json=payload)
Could you please help me understand where I might be going wrong?