Get Tickets - Authentication Error

Hello there, I’m running an api call on tickets using my private app api key that has tickets added to the scope. The hubspot dash is showing that the call is successful however the response is giving an authentication error
Here is my api call

import requests
import json

url = 'https://api.hubapi.com/crm/v3/objects/tickets?limit=100&archived=false'
headers ={}
headers['authorization'] = 'Bearer [private app token]'

r = requests.get(url)
results = r.json()

Attached is the screenshot showing the successful logs

Here is the error I’m getting

{'status': 'error', 'message': 'Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview', 'correlationId': '50c4299e-412a-4152-b3a4-77546f85f33d', 'category': 'INVALID_AUTHENTICATION'}

Very confused on how to approach this because I feel like everything I’m doing is correct per the docs.

Hey, @zmcCarty5456 :waving_hand: Thanks for reaching out. Quick questions:

  • Is this happening when you use the Python example from this page? — CRM API | Tickets
  • I ran a quick test using that example with a Private App that has only the Tickets scope

  • It returned both the 200 Response and the expected response body

    import hubspot
    from pprint import pprint
    from hubspot.crm.tickets import ApiException
    
    client = hubspot.Client.create(access_token="YOUR_ACCESS_TOKEN")
    
    try:
     api_response = client.crm.tickets.basic_api.get_page(limit=100, archived=False)
     pprint(api_response)
    except ApiException as e:
     print("Exception when calling basic_api->get_page: %s\n" % e)
    
    HTTP 200
    
    {
     "results": [
     {
     "id": "999396896",
     "properties": {
     "content": null,
     "createdate": "2022-07-14T16:08:40.033Z",
     "hs_lastmodifieddate": "2022-10-24T20:09:44.395Z",
     "hs_object_id": "999396896",
     "hs_pipeline": "0",
     "hs_pipeline_stage": "1",
     "hs_ticket_category": null,
     "hs_ticket_priority": "HIGH",
     "subject": "troubleshoot report"
     },
     "createdAt": "2022-07-14T16:08:40.033Z",
     "updatedAt": "2022-10-24T20:09:44.395Z",
     "archived": false
     },
     {
     "id": "1046754424",
     "properties": {
     "content": "This is a test form submission",
     "createdate": "2022-08-11T23:23:54.489Z",
     "hs_lastmodifieddate": "2022-09-14T12:25:22.358Z",
     "hs_object_id": "1046754424",
     "hs_pipeline": "0",
     "hs_pipeline_stage": "1",
     "hs_ticket_category": null,
     "hs_ticket_priority": null,
     "subject": "New form channel connected"
     },
     "createdAt": "2022-08-11T23:23:54.489Z",
     "updatedAt": "2022-09-14T12:25:22.358Z",
     "archived": false
     },
     {
     "id": "1317382811",
     "properties": {
     "content": null,
     "createdate": "2022-12-13T20:34:07.713Z",
     "hs_lastmodifieddate": "2022-12-13T20:34:09.268Z",
     "hs_object_id": "1317382811",
     "hs_pipeline": "0",
     "hs_pipeline_stage": "2",
     "hs_ticket_category": null,
     "hs_ticket_priority": "HIGH",
     "subject": null
     },
     "createdAt": "2022-12-13T20:34:07.713Z",
     "updatedAt": "2022-12-13T20:34:09.268Z",
     "archived": false
     },
     {
     "id": "1317387588",
     "properties": {
     "content": null,
     "createdate": "2022-12-13T20:26:40.691Z",
     "hs_lastmodifieddate": "2022-12-13T20:26:43.223Z",
     "hs_object_id": "1317387588",
     "hs_pipeline": "0",
     "hs_pipeline_stage": "2",
     "hs_ticket_category": null,
     "hs_ticket_priority": "HIGH",
     "subject": null
     },
     "createdAt": "2022-12-13T20:26:40.691Z",
     "updatedAt": "2022-12-13T20:26:43.223Z",
     "archived": false
     }
     ]
    }
    

  • I’m curious if we can look for something simple regarding the differences

Thanks for adding any additional details. We have several community members who help with all things Python-related that I am happy to tag as well.

Best,

Jaycee

Hey @Jaycee_Lewis I see that you are using the Hubspot library in yoru request. I will give this a try later today and get back to you.