Create pull request and add labels in a single request #24724
-
Hi there, I’m trying to create a pull request with labels in a single request via Github’s REST (v3) API. To be sure I did try creating a PR with
Is this possible with the current REST (v3) api or via the graphql (v4) api? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
You are correct that there isn’t a way to do what you’re describing using the REST API. Additionally, there isn’t a way to add labels via the GraphQL API Perhaps someone more experienced with GraphQL could comment on a way to make it happen. |
Beta Was this translation helpful? Give feedback.
-
Hi @sqren Thanks for being here, while I have no input as to how to add this programmatically at creation via the API (I’m not sure this is possible. When using the API, adding labels takes two steps: PR saved first then labels are saved to the database vs in the UI is done in one step) I hope that helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks both. I’ll have to make due with multiple requests (In addition to adding labels I also need to add assignees to the PR). Would be great if this could be done at creation time like it’s possible with issues. |
Beta Was this translation helpful? Give feedback.
-
Just completing the answer as I just experienced something similar: To add labels to a PR with the Github API, it’s necessary to call 2 endpoints:
The Note 1: You can also pass an empty array to remove all labels. Note 2: You can also pass a single label as a string or an array of labels directly, but GitHub recommends passing an object with the labels key. |
Beta Was this translation helpful? Give feedback.
-
Hello my friend, can you say me about my web or phone problem? |
Beta Was this translation helpful? Give feedback.
Thanks both. I’ll have to make due with multiple requests (In addition to adding labels I also need to add assignees to the PR).
Would be great if this could be done at creation time like it’s possible with issues.