I am trying to update tasks using Python 3.9 for learning purposes.
I tried several ways to resolve this error but the error persists.
The error:
[ERROR] ApiException: (401)
Reason: Unauthorized
HTTP response body: {"status":"error","message":"Authentication credentials not found."}
The code I am using:
url = 'https://api.hubapi.com/crm/v3/objects/tasks/' + task.id
auth = os.getenv('HAPIKEY')
payload = "{\"properties\":{\"hs_task_status\":\"COMPLETED\"}}"
headers = {
'accept': 'application/json',
'content-type': 'application/json',
'authorization': 'Bearer '+auth
}
response = requests.request(
"PATCH", url, data=payload, headers=headers)