Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
As title says, it seems not possible to add a label to a PR through existing REST API. A /repos/{owner}/{repo}/pulls/{index} PATCH request using { "labels": [ 182 ] } as body (with that label being present for that repo) returns a 201 but the label is not added.
when using this approach xorm.log yields (selects omitted):
whereas, when manually adding the label to the PR, xorm.log shows (selects also omitted):
2018/11/30 13:19:03 [I] [SQL] UPDATE `webhook` SET `last_status` = ?, `updated_unix` = ? WHERE `id`=? []interface {}{1, 1543583943, 208}
2018/11/30 13:19:04 [I] [SQL] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? []interface {}{true, 5, 14879}
2018/11/30 13:19:26 [I] [SQL] BEGIN TRANSACTION
2018/11/30 13:19:26 [I] [SQL] INSERT INTO `issue_label` (`issue_id`,`label_id`) VALUES (?, ?) []interface {}{14879, 182}
2018/11/30 13:19:26 [I] [SQL] INSERT INTO `comment` (`type`,`poster_id`,`issue_id`,`label_id`,`old_milestone_id`,`milestone_id`,`assignee_id`,`removed_assignee`,`old_title`,`new_title`,`dependent_issue_id`,`commit_id`,`line`,`tree_path`,`content`,`patch`,`created_unix`,`updated_unix`,`commit_sha`,`review_id`,`invalidated`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) []interface {}{7, 5, 14879, 182, 0, 0, 0, false, "", "", 0, 0, 0, "", "1", "", 1543583966, 1543583966, "", 0, false}
2018/11/30 13:19:26 [I] [SQL] UPDATE `issue` SET `updated_unix` = ? WHERE `id`=? []interface {}{1543583966, 14879}
2018/11/30 13:19:26 [I] [SQL] UPDATE `label` SET `repo_id` = ?, `name` = ?, `description` = ?, `color` = ?, `num_issues` = ?, `num_closed_issues` = ? WHERE `id`=? []interface {}{276, "lgtm/need 1", "needs another review in order to be merged", "#fbca04", 1, 0, 182}
2018/11/30 13:19:26 [I] [SQL] COMMIT
Current workaround is to use instead a PUT request to /repos/{owner}/{repo}/issues/{index}/labels using the same index and set the label on the PR through the issues endpoint
[x]
):Description
As title says, it seems not possible to add a label to a PR through existing REST API. A
/repos/{owner}/{repo}/pulls/{index}
PATCH request using{ "labels": [ 182 ] }
as body (with that label being present for that repo) returns a 201 but the label is not added.when using this approach xorm.log yields (selects omitted):
whereas, when manually adding the label to the PR, xorm.log shows (selects also omitted):
Current workaround is to use instead a
PUT
request to/repos/{owner}/{repo}/issues/{index}/labels
using the same index and set the label on the PR through theissues
endpoint