APIs & Integrations

EKnizhnik
Member

Workflow Custom Code: Ticket to Tasks

Hey, everyone!

I am trying to set up a Workflow with Custom Code which, upon the creation of a new Ticket, sets up a corresponding Task where the Task's Due Date is the same at the Ticket's Waiting on Follow Up Date property. My current issue is that I cannot set up a call to grab tickets. Using 
hubspotClient.crm.objects.tickets.basicApi.getById I get an error that that object does not exist. Using hubspotClient.crm.tickets.basicApi.getById I get a 401 error code with an Invalid Authentication (the only scopes under this key are "tickets" and "objects.contacts.read and write" for the tasks). 

How could I go about solving this? If you have any suggestions on how I can achieve the goal of the custom code, I would appreciate it too! 

Thank you so much!

0 Upvotes
2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

Workflow Custom Code: Ticket to Tasks

Hey, @EKnizhnik 👋 Can you share any additional details? Seeing how your request is set up along with the response and full error body may give our community members more to work with to assist you.

 

Best,

Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
EKnizhnik
Member

Workflow Custom Code: Ticket to Tasks

Hi, @Jaycee_Lewis, absolutely! I am calling (copied from Hubspot test calls, which works. It is not calling in the waiting_on_follow_up_date property though. I double checked, I am using the same credentials in both the test calls and my custom code):

const properties = [
  "waiting_on_follow_up_date"
];
const propertiesWithHistory = undefined;
const associations = undefined;
const archived = false;
const idProperty = undefined;

try {
  const apiResponse = await hubspotClient.crm.tickets.basicApi.getById(ticketId, properties, propertiesWithHistory, associations, archived, idProperty);

and I get this long error respone (truncated): 

HTTP-Code: 401
Message: An error occurred.
Body: {"status":"error","message":"Authentication credentials not found. This API supports OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview","correlationId":"b4a75328-dae7-49be-b380-1f9c564d6ba8","category":"INVALID_AUTHENTICATION"}
Headers: {"access-control-allow-credentials":"false","cf-cache-status":"DYNAMIC","cf-ray":"8a2456ef0af93944-IAD","connection":"keep-alive","content-len
2024-07-12T22:06:17.492Z	INFO	... [Log truncated]

 

Let me know if any other information will be helpful. I could also export the whole code if you need me to. 

 

Thank you again!