GitLab API v4仅收集不到20条问题评论。

huangapple go评论53阅读模式
英文:

GitLab API v4 only collects less than 20 issue comments

问题

如果我在一个问题中收集所有问题,JSON字符串中只会显示20条评论。
原因: 默认分页

如果我在一个里程碑中收集所有问题,我可以使用参数per_page=100

$ key="$PRIVATE_TOKEN"
$ proj_url="https://<URL>/api/v4/projects/$CI_PROJECT_ID"
$ curl -s --header "PRIVATE-TOKEN: $key" "$proj_url/issues?milestone=<MILESTONE NAME>&per_page=100"

我如何使用GitLab API收集所有问题备注?

$ key="$PRIVATE_TOKEN"
$ proj_url="https://<URL>/api/v4/projects/$CI_PROJECT_ID"
$ curl -s --header "PRIVATE-TOKEN: $key" "$proj_url/issues/193/notes"
英文:

If I collect all issues within an Issue only 20 comments will be shown in the JSON string.
Reason: Default Pagination

If I collect all Issues within an Milestone I can use the parameter per_page=100.

$ key=&quot;$PRIVATE_TOKEN&quot;
$ proj_url=&quot;https://&lt;URL&gt;/api/v4/projects/$CI_PROJECT_ID&quot;
$ curl -s --header &quot;PRIVATE-TOKEN: $key&quot; &quot;$proj_url/issues?milestone=&lt;MILESTONE NAME&gt;&amp;per_page=100&quot;

How can I collect all issue notes with GitLab API?

$ key=&quot;$PRIVATE_TOKEN&quot;
$ proj_url=&quot;https://&lt;URL&gt;/api/v4/projects/$CI_PROJECT_ID&quot;
$ curl -s --header &quot;PRIVATE-TOKEN: $key&quot; &quot;$proj_url/issues/193/notes&quot;

答案1

得分: 1

The GitLab Notes API confirms that, by default, GET requests return 20 results at a time because the API results are paginated. But per_page=100 should still be available for this type of query.

The other option would be to use the GitLab CLI glab to make the same query with glab api, but with --paginate

In '­­--paginate' mode, all pages of results will sequentially be requested until there are no more pages of results.

英文:

The GitLab Notes API confirms that, by default, GET requests return 20 results at a time because the API results are paginated.
But per_page=100 should still be available for this type of query.

The other option would be to use the GitLab CLI glab to make the same query with glab api, but with --paginate

> In '--paginate' mode, all pages of results will sequentially be requested until there are no more pages of results.

huangapple
  • 本文由 发表于 2023年4月11日 14:23:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75982941.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定