Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/GitHub/GitHub_Delete_an_issue_comment.ipynb
2973 views
Kernel: Python 3

GitHub.png

GitHub - Delete an issue comment

Give Feedback | Bug report

Tags: #github #issue #comment #api #python #library

Last update: 2023-05-26 (Created: 2023-05-26)

Description: This notebook shows how to delete a comment to an issue on GitHub.

Input

Import libraries

import requests import naas

Setup Variables

  • token: GitHub token

  • owner: owner of the repository

  • repo: name of the repository

  • comment_id: Id of comment to be deleted. To find it, you can use "GitHub - List issue comments"

token = naas.secret.get('GITHUB_TOKEN') owner = "jupyter-naas" repo = "awesome-notebooks" comment_id = 1563983688

Model

Delete an issue comment

def delete_issue_comment( token=None, owner=None, repo=None, comment_id=None ): # URL url = f"https://api.github.com/repos/{owner}/{repo}/issues/comments/{comment_id}" # Set the request headers headers = { "Authorization": f"token {token}", "Content-Type": "application/json" } # Send the POST request res = requests.delete(url, headers=headers) if res.status_code == 204: print(f"✅ Comment deleted on issue") return res else: print(res.status_code, res.json())

Output

Display result

delete_issue_comment(token, owner, repo, comment_id)