How to comment on clickup with python?

199 Views Asked by At

I want to comment on a specific task in clickup but it responses 401 error.

url = "https://api.clickup.com/api/v2/task/861m8wtw3/comment"

headers = {
    "Authorization": "Bearer <my api key>",
    "Content-Type": "application/json"
}

# comment = input('Type your comment text: \n')
comment = 'test comment'

data = {
    "content": f"{comment}"
}

response = requests.post(url, headers=headers, json=data)

and the output is:

<Response [401]>

what is the problem?

i tried to add mozilla headers as the user agent key:

'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'

but still get the 401 error!

1

There are 1 best solutions below

1
gpnr On

It looks like the issue is with the Authorization header. Make sue that the header only includes the API token string, without 'Bearer' in front of it. Like so:

headers = {
    "Authorization": "<your api token>",
    "Content-Type": "application/json"
}