import requests import json import hubspot from pprint import pprint from hubspot.crm.objects.notes import ApiException def no_client(): COMPANYID = "5951571334" headers = { "Authorization": "Bearer pat-na1-9f41f073-95e2-4eea-b0c9-3e9571a3998c", } # url = "https://api.hubapi.com/crm/v3/objects/companies?limit=10&archived=false" # url = "https://api.hubapi.com/crm/v3/objects/notes?limit=100&archived=false&properties=hubspot_owner_id,hs_note_body" # url = f"https://api.hubapi.com/crm/v4/objects/companies/{COMPANYID}/associations/notes" url = f"https://api.hubapi.com/engagements/v1/engagements/" # 36317682030" # associated/COMPANY/{COMPANYID}" response = requests.get(url, headers=headers) jsontext = response.json() print(jsontext) # for item in jsontext['results']: # for props in item['properties']: # if item['properties']['hubspot_owner_id'] == '2757824': # print(item) # props = json.dumps(props, indent=2) # formatted = json.dumps(jsontext, indent=2) # print(jsontext) # for item in jsontext['results']: # if item['engagement']['type'] == 'NOTE': # # pass # print(item) # if item['engagement']['type'] == 'NOTE': def hubspot_client(): client = hubspot.Client.create( access_token="pat-na1-9f41f073-95e2-4eea-b0c9-3e9571a3998c" ) # try: # api_response = client.crm.objects.notes.basic_api.get_page( # limit=10, properties=['hs_note_body', 'id'], # associations=['Company'], archived=False # ) # pprint(api_response) # except ApiException as e: # print("Exception when calling basic_api->get_page: %s\n" % e) try: api_response = client.crm.objects.notes.basic_api.get_page( archived=False, properties=["hs_note_body", "hubspot_owner_id", "id"] ) api = api_response.to_dict() print(type(api)) # pprint(api_response) except ApiException as e: print("Exception when calling basic_api->get_by_id: %s\n" % e) if __name__ == "__main__": no_client() # hubspot_client()