Cannot add tickets scope to the authorizationUrl

SOLVE
Highlighted
Occasional Contributor

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);
}

 

 

Reply
0 Upvotes
2 Accepted solutions

Accepted Solutions
HubSpot Moderator

Hi, @kawyns1.

 

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 SettingsUsers & Teams[Your user], you will see this:

 

Super Admin.jpg

Are you disconnecting your app from within Settings > IntegrationsApps before you go back through the OAuth flow requesting the tickets scope with your user?

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
HubSpot Moderator

Hi, @kawyns1.

 

Correct, the Tickets API doesn't support the includeAssociations parameter used in some older CRM object endpoints.

 

To get the objects associated with tickets, you'll have to use this CRM Associations API endpoint.

 

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"):

 

https://api.hubapi.com/crm-associations/v1/associations/12345/HUBSPOT_DEFINED/16

You would have to loop this request to retrieve associations for all tickets. 

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
9 Replies 9
HubSpot Moderator

Hi, @kawyns1.

 

Happy to help.

 

Make sure that the user connecting the integration is either a Super Admin or has full read/write access to ticket objects:

 

Screen Shot 2019-07-31 at 5.51.33 PM.png

 

If you believe everything is set up correctly, please share your Hub ID and the user's email in our direct message.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Occasional Contributor

Hi Isaac,

 

Thank you for helping out with this. I am the super admin for the developer account, how do I get to the page that you have shown in the screenshot?

 

Regards,

Kawyn

Reply
0 Upvotes
HubSpot Moderator

Hi, @kawyns1.

 

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 SettingsUsers & Teams[Your user], you will see this:

 

Super Admin.jpg

Are you disconnecting your app from within Settings > IntegrationsApps before you go back through the OAuth flow requesting the tickets scope with your user?

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Occasional Contributor

Hi Isaac,

 

That is what I ended up doing. The tickets are flowing through right now.

 

Thanks,

Kawyn

HubSpot Moderator

Glad to hear it, @kawyns1!

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Occasional Contributor

Hi Isaac,

 

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

 

Thanks,

Kawyn

Reply
0 Upvotes
HubSpot Moderator

Hi, @kawyns1.

 

Correct, the Tickets API doesn't support the includeAssociations parameter used in some older CRM object endpoints.

 

To get the objects associated with tickets, you'll have to use this CRM Associations API endpoint.

 

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"):

 

https://api.hubapi.com/crm-associations/v1/associations/12345/HUBSPOT_DEFINED/16

You would have to loop this request to retrieve associations for all tickets. 

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes
Occasional Contributor

Hi Isaac,

 

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.

 

Thanks,

Kawyn

Reply
0 Upvotes
HubSpot Moderator

Hi, @kawyns1.

 

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.

Isaac Takushi

HubSpot Developer Support
Reply
0 Upvotes