0

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!

Sadegh Pouriyan
  • 157
  • 1
  • 10
  • Any chance your authorization value in the headers needs to be in base64? – PApostol Jan 29 '23 at 13:57
  • No, the problem was that the headers dictionary needed another key named "User-Agent". Besides as @gpnr said, there is no need to include 'Bearer' in front of it. – Sadegh Pouriyan Feb 18 '23 at 16:01

1 Answers1

0

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"
}
gpnr
  • 121
  • 5