How to change a PR to draft from the api with Curl #45174
Replies: 4 comments 9 replies
-
|
Good day @macpharlan To convert a pull request to a draft, you can use the PATCH /repos/{owner}/{repo}/pulls/{pull_number} endpoint, and set the state field to "draft" in the request body. you can use curl to convert a pull request to a draft: curl -X PATCH -H "Authorization: token YOUR_TOKEN" -H "Content-Type: application/json" -d '{"state": "draft"}' https://api.github.com/repos/OWNER/REPO/pulls/PULL_NUMBER Just replace YOUR_TOKEN with your GitHub token, OWNER with the repository owner's username, REPO with the repository name, and PULL_NUMBER with the number of the pull request you want to convert. just make-sure you have write access to the repository. |
Beta Was this translation helpful? Give feedback.
-
|
@macpharlan as you ended up finding out, the v3 API will return whether a PR is draft, but it does not support updating the draft status (the Update a Pull Request endpoint only allows setting the title, body, state, base, and "Allow edits from maintainers" properties). It would be really useful if that was added to the v3 API, but so far that's remained a graphql-only feature. |
Beta Was this translation helpful? Give feedback.
-
|
With the |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Question
Body
We have a need to change PR to draft through the API. We have not been able to find any documentation on this and are searching for help.
I see a 'convert_to_draft' in the GUI but need to do it automatically using curl.
Beta Was this translation helpful? Give feedback.
All reactions