Hi All,
Just to preface i am a complete beginner with code. What i am trying to accomplish is a note being created on an enrolled ticket that contains special instruction on how to handle specific customers. the code i have cobbled together is as follows, (using a private app)
const hubspot = require(‘@hubspot/api-client’);
exports.main = async () => {
const token = process.env.OPS_TOKEN
const hubspotClient = new hubspot.Client({“accessToken”:token});
const properties = {
“hs_timestamp”: Date.now(), // Current time/date,
“hs_note_body”: “testing note creation” // Body of the note,
};
const SimplePublicObjectInputForCreate = { associations: [{“types”:[{“associationCategory”:“HUBSPOT_DEFINED”,“associationTypeId”:228}],“to”:{“id”:“hs_object_id”}}], properties };
try {
const apiResponse = await hubspotClient.crm.objects.notes.basicApi.create(SimplePublicObjectInputForCreate);
console.log(JSON.stringify(apiResponse, null, 2));
} catch (e) {
e.message === ‘HTTP request failed’
? console.error(JSON.stringify(e.response, null, 2))
: console.error(e)
}}
WARNING: The logs for this function have exceeded the 4KB limit.
...
,"context":{"id":["hs_object_id"]},"category":"OBJECT_NOT_FOUND"}
Headers: {"access-control-allow-credentials":"false","cf-cache-status":"DYNAMIC","cf-ray":"8ab64e11bbadc946-IAD","connection":"keep-alive","content-encoding":"gzip","content-type":"application/json;charset=utf-8","date":"Tue, 30 Jul 2024 15:15:35 GMT","nel":"{\"success_fraction\":0.01,\"report_to\":\"cf-nel\",\"max_age\":604800}","report-to":"{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=DlL2tufyf5hwqkNFpqnuX1ooIs%2B4mzKw%2BXYeaASlUElsAdZJK4IMEFczXc8W4qSgoTq2y1VLlyU09bIXqh2lWQQyukyHRbZ2J6LFz1%2Fto32IMZvDDE3zh0sU6Mq%2BHTkr\"}],\"group\":\"cf-nel\",\"max_age\":604800}","server":"cloudflare","strict-transport-security":"max-age=31536000; includeSubDomains; preload","transfer-encoding":"chunked","vary":"origin, Accept-Encoding","x-content-type-options":"nosniff","x-envoy-upstream-service-time":"71","x-evy-trace-listener":"listener_https","x-evy-trace-route-configuration":"listener_https/all","x-evy-trace-route-service-name":"envoyset-translator","x-evy-trace-served-by-pod":"iad02/hubapi-td/envoy-proxy-7dd59b876-tndmq","x-evy-trace-virtual-host":"all","x-hubspot-correlation-id":"9eb78ec2-5940-48fb-b9bf-57785fe8c203","x-hubspot-notfound":"true","x-hubspot-ratelimit-daily":"500000","x-hubspot-ratelimit-daily-remaining":"499994","x-hubspot-ratelimit-interval-milliseconds":"10000","x-hubspot-ratelimit-max":"150","x-hubspot-ratelimit-remaining":"149","x-hubspot-ratelimit-secondly":"15","x-hubspot-ratelimit-secondly-remaining":"14","x-request-id":"9eb78ec2-5940-48fb-b9bf-57785fe8c203"}
at BasicApiResponseProcessor.<anonymous> (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/objects/notes/apis/BasicApi.js:209:23)
at Generator.next (<anonymous>)
at fulfilled (/opt/nodejs/node_modules/@hubspot/api-client/lib/codegen/crm/objects/notes/apis/BasicApi.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 404,
body: {
status: 'error',
message: 'Object not found. objectId are usually numeric.',
correlationId: '9eb78ec2-5940-48fb-b9bf-57785fe8c203',
context: { id: [Array] },
category: 'OBJECT_NOT_FOUND'
},
headers: {
'access-control-allow-credentials': 'false',
'cf-cache-status': 'DYNAMIC',
'cf-ray': '8ab64e11bbadc946-IAD',
connection: 'keep-alive',
'content-encoding': 'gzip',
'content-type': 'application/json;charset=utf-8',
date: 'Tue, 30 Jul 2024 15:15:35 GMT',
nel: '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}',
'report-to': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v4?s=DlL2tufyf5hwqkNFpqnuX1ooIs%2B4mzKw%2BXYeaASlUElsAdZJK4IMEFczXc8W4qSgoTq2y1VLlyU09bIXqh2lWQQyukyHRbZ2J6LFz1%2Fto32IMZvDDE3zh0sU6Mq%2BHTkr"}],"group":"cf-nel","max_age":604800}',
server: 'cloudflare',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload',
'transfer-encoding': 'chunked',
vary: 'origin, Accept-Encoding',
'x-content-type-options': 'nosniff',
'x-envoy-upstream-service-time': '71',
'x-evy-trace-listener': 'listener_https',
'x-evy-trace-route-configuration': 'listener_https/all',
'x-evy-trace-route-service-name': 'envoyset-translator',
'x-evy-trace-served-by-pod': 'iad02/hubapi-td/envoy-proxy-7dd59b876-tndmq',
'x-evy-trace-virtual-host': 'all',
'x-hubspot-correlation-id': '9eb78ec2-5940-48fb-b9bf-57785fe8c203',
'x-hubspot-notfound': 'true',
'x-hubspot-ratelimit-daily': '500000',
'x-hubspot-ratelimit-daily-remaining': '499994',
'x-hubspot-ratelimit-interval-milliseconds': '10000',
'x-hubspot-ratelimit-max': '150',
'x-hubspot-ratelimit-remaining': '149',
'x-hubspot-ratelimit-secondly': '15',
'x-hubspot-ratelimit-secondly-remaining': '14',
'x-request-id': '9eb78ec2-5940-48fb-b9bf-57785fe8c203'
}
}
Memory: 87/128 MB
Runtime: 522.71 ms

