Hi there,
I’m currently trying to run a webhook to add a new hook and a new key on each new project, via a system webhook.
The hook creation via the API wasn’t a problem at all, but the key is more a problem to me
def createkey(project_id):
data={}
data["id"]='%s' % project_id
data["title"]='%s' % title
data['key']="%s" % key
url='https://mygitlab.com/api/v3/projects/%s/keys' % (str(project_id))
r = requests.post(url, '%s' % data, headers=headers)
print url, data, r.status_code
return r.status_code
It always returns a 400 HTTP code, I even tried with curl to debug and obtain the exact same thing :
curl -H "content-type: application/json" -H "PRIVATE-TOKEN: mytoken" -H "Accept: application/json" -X POST --insecure https://mygitlabcom/api/v3/projects/$projectid/keys -d "{'key': 'ssh-rsa mykey root@myhost 'title': 'myname', 'id': '701'}"
{"status":"400","error":"Bad Request"}
n.b. : I am using the format presented here : http://tldrify.com/d35
