Reputation: 1798
I am trying to use the Gitlab API to make an issue from Python.
The following curl request works (tested and confirmed):
curl --request POST --header "PRIVATE-TOKEN: <my token>" https://gitlab.com/api/v3/projects/<my project id>/issues?title=Issues%20with%20auth&labels=bug
My Python code:
import requests
r = requests.post("https://gitlab.com/api/v3/projects/2674887/issues", data={
"title":issueform.instance.title,
"description":issueform.instance.description
},
headers={"PRIVATE_TOKEN":"<token>"})
print(r.status_code, r.reason)
I get: 401 Unauthorized
Am I doing something wrong in my POST request or is this an issue with GitLab rejecting doing it this way possibly?
The relevant part from the API: http://docs.gitlab.com/ee/api/issues.html#new-issue
EDIT:
Forgot to mention, ignore the issueform.instance
stuff, they are just Strings (it is a Django project and I omitted the form stuff because it shouldn't be relevant)
Upvotes: 5
Views: 7315
Reputation: 925
Maybe it just a typo? could you try the below?
"PRIVATE-TOKEN"
instead of
"PRIVATE_TOKEN"
Upvotes: 1