How to access GitLab issues using CURL?

我只是一个虾纸丫 提交于 2019-12-09 14:34:51

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!