⚙ Operations Hub

AbdulRahim
参加者

Error while using custom code to update task

解決

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)

 

 

1件の承認済みベストアンサー
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

Error while using custom code to update task

解決

Hi @AbdulRahim ,

 

It seems as if you are trying to pass an API key in the authorization header, which will not work.

API keys are getting sunset, so your go-to authentication method should be a private app

I'm pretty positive that if you use a private app token in your code instead of the API key, it should work. Just make sure you have the right scope selected.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.


元の投稿で解決策を見る

1件の返信
Teun
解決策
名誉エキスパート | Diamond Partner
名誉エキスパート | Diamond Partner

Error while using custom code to update task

解決

Hi @AbdulRahim ,

 

It seems as if you are trying to pass an API key in the authorization header, which will not work.

API keys are getting sunset, so your go-to authentication method should be a private app

I'm pretty positive that if you use a private app token in your code instead of the API key, it should work. Just make sure you have the right scope selected.



Learn more about HubSpot by following me on LinkedIn or YouTube

Did my answer solve your issue? Help the community by marking it as the solution.