Hi,
I am trying create deploy-keys for a certain repository but it keeps giving me this response:
<Response [400]>
{"key": [{"message": "This field is required.", "code": "required"}]}
There is no reference in the documentation about this: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/deploy-keys#post
my setup:
NOTE: the ssh-key is the same as in the docs so no harm in showing, it is for testing.
import requests
import json
user = "******"
password = "*******"
repo = "******"
auth = requests.auth.HTTPBasicAuth(user, password)
host = "https://api.bitbucket.org"
headers = {"content-type": "application/json"}
payload = {
"code": 1,
"key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDAK/b1cHHDr/TEV1JGQl+WjCwStKG6Bhrv0rFpEsYlyTBm1fzN0VOJJYn4ZOPCPJwqse6fGbXntEs+BbXiptR+++HycVgl65TMR0b5ul5AgwrVdZdT7qjCOCgaSV74/9xlHDK8oqgGnfA7ZoBBU+qpVyaloSjBdJfLtPY/xqj4yHnXKYzrtn/uFc4Kp9Tb7PUg9Io3qohSTGJGVHnsVblq/rToJG7L5xIo0OxK0SJSQ5vuId93ZuFZrCNMXj8JDHZeSEtjJzpRCBEXHxpOPhAcbm4MzULgkFHhAVgp4JbkrT99/wpvZ7r9AdkTg7HGqL3rlaDrEcWfL7Lu6TnhBdq5 mleu@C02W454JHTD8",
"label": "mydeploykey",
}
post = "/2.0/repositories/wegroupwolves/{repo}/deploy-keys".format(repo=repo)
r = requests.post(host + post, auth=auth, data=json.dumps(payload))
print(r, r.text
Hello Sebastiaan and welcome to the Community!
We researched why this was causing an issue and why you're being presented with this required field. We found the following within your header should resolve the issue:
r = requests.post(host + post, auth=auth, data=json.dumps(payload))
To
r = requests.post(host + post, auth=auth, headers=headers, data=json.dumps(payload))
Please let us know if this helps to resolve your required field error.
Regards,
Stephen Sifers
Oh my ... What a mistake.
Thank you very much for replying!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.