问题
I'd like to get a list of the issues for the project YYYYYY
and a username XXXXXX
.
curl --header "PRIVATE-TOKEN: myownprivatetoken" "https://gitlab.com/api/v3/projects/YYYYYY/issues"
curl --header "PRIVATE-TOKEN: myownprivatetoken" --header "SUDO: XXXXXX" "https://gitlab.com/api/v3/projects/YYYYYY/issues"
curl --header "PRIVATE-TOKEN: myownprivatetoken" "https://gitlab.com/api/v3/XXXXXX/projects/YYYYYY/issues"
But they only return:
{"message":"404 Project Not Found"}
or
<html><body>You are being <a href="https://gitlab.com/users/sign_in">redirected</a>.</body></html>
It seems to me that I have misinterpreted the API docs at http://doc.gitlab.com/ce/api/issues.html and http://doc.gitlab.com/ce/api/README.html .
So what am I doing wrong?
回答1:
The documentation tell you this about how to retrieve issues from a project:
GET /projects/:id/issues
And you tried:
curl --header "PRIVATE-TOKEN: xxx" "https://gitlab.com/api/v3/projects/YYYYYY/issues"
This is correct, but the parameter you give YYYYYY
has to be the project id, so it has to be an integer, not text with the project name or path. You need to use something like :
curl --header "PRIVATE-TOKEN: xxx" "https://gitlab.com/api/v3/projects/234/issues"
Where 234
is the id of your project. To get this integer id of your project, simply do a :
curl --header "PRIVATE-TOKEN: xxx" "https://gitlab.com/api/v3/projects
This will list all your projects and will give you the unique integer identifier of a project in the id
field:
[
{
"id": 4, <-------- //This one
"name": "my super mega project",
"description": null,
.....
来源:https://stackoverflow.com/questions/31805041/how-to-access-gitlab-issues-using-curl