Hi, when I try to add another scope (tickets) to my authorizationUrl, it still does not let me access my tickets. This is the error message I receive:
Request failed for https://api.hubapi.com/crm-objects/v1/objects/tickets/paged?properties=subject returned code 400. Truncated server response: {"status":"error","message":"Must have scope TICKETS_READ","correlationId":"64708665-4ba9-494d-9499-8044725d896a","requestId":"f5464e11-d5ff-4660-9... (use muteHttpExceptions option to examine full response) (line 27, file "getTickets"
My authentication code goes as follows:
var CLIENT_ID = 'client_id_hidden'; // Enter your Client ID
var CLIENT_SECRET = 'client_secret_hidden'; // Enter your Client secret
var SCOPE = 'contacts%20tickets'; // Change the scope based on Hubspot API page
var AUTH_URL = 'https://app.hubspot.com/oauth/authorize';
var TOKEN_URL = 'https://api.hubapi.com/oauth/v1/token';
var API_URL = 'https://api.hubapi.com';
function getService() {
return OAuth2.createService('hubspot')
.setTokenUrl(TOKEN_URL)
.setAuthorizationBaseUrl(AUTH_URL)
.setClientId(CLIENT_ID)
.setClientSecret(CLIENT_SECRET)
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties())
.setScope(SCOPE);
}
Are you referring to the developer test account ending in 1347? I see that you are a Super Admin in that account.
As such, you won't see the toggles shown in the screenshot because super admins have all permissions in a given account. In Settings > Users & Teams > [Your user], you will see this:
Are you disconnecting your app from within Settings > Integrations > Appsbefore you go back through the OAuth flow requesting the tickets scope with your user?
The objectId you'll use is the same ticket objectId returned from this endpoint. You can then use the definition ID key on this page to determine the correct definitionId value.
For example, if I want to see the contacts associated with ticket 12345, I would use the following request URL (definition ID 16 is "ticket to contact"):
Are you referring to the developer test account ending in 1347? I see that you are a Super Admin in that account.
As such, you won't see the toggles shown in the screenshot because super admins have all permissions in a given account. In Settings > Users & Teams > [Your user], you will see this:
Are you disconnecting your app from within Settings > Integrations > Appsbefore you go back through the OAuth flow requesting the tickets scope with your user?
So I'm trying to get all the associations for my tickets. The get all tickets api does not seem to have an includeAssociations=true functionality. I am thinking of trying the CRM associations api but it seems I need to include a specfic objectID like a ticket ID.
How can I get the associations for all the tickets
The objectId you'll use is the same ticket objectId returned from this endpoint. You can then use the definition ID key on this page to determine the correct definitionId value.
For example, if I want to see the contacts associated with ticket 12345, I would use the following request URL (definition ID 16 is "ticket to contact"):
Thanks for your reply. It seems looping is the only option. Is it possible to get associations via the deals API? For example, getting the associated tickets of all deals via the get all deals and then joining them together instead of looping through all the tickets.
Yes, tickets associated with deals will be returned in the associatedTicketIds array in the associations object if you include the includeAssociations=true parameter when querying this endpoint.
This approach assumes that all tickets are associated with deals.