Hi all,
I’m trying to create a task in Hubspot using an API call from a Google Sheet (using Google Script). I’ve sorted through the API etc using Postman until my code worked, but when I use the same set-up in Google Script, I keep getting error 415:
Exception: Request failed for https://api.hubspot.com returned code 415
function hsAPI_Task() {
const options = {
method: "POST",
muteHttpExceptions: false,
headers: {
accept: "application/json",
Authorization: "Bearer <hidden for privacy>",
},
body: {
"properties": {
"hs_timestamp": "2024-10-30T03:30:17.883Z",
"hs_task_body": "Send test",
"hubspot_owner_id": "<hidden for privacy>",
"hs_task_subject": "Test Task",
"hs_task_status": "WAITING",
"hs_task_priority": "HIGH",
"hs_task_type": "CALL"
},
"associations": [{
"to": {
"id": <hidden for privacy>
},
"types": [{
"associationCategory": "HUBSPOT_DEFINED",
"associationTypeId": 18
}]
}]
},
};
var r = UrlFetchApp.fetch("https://api.hubspot.com/crm/v3/objects/tasks", options);
console.log(r);
}
Any smart insights in what is going wrong or causing the error?