I need to create marketing events (like webinar data) in Hubspot taking data from cells in Google Sheets. Marketing events are inside Contacts -> Contacts -> Marketing events. Here is Hubspot API documentation on marketing events https://developers.hubspot.com/docs/api/marketing/marketing-events
I failed to get a request so far.
Here is what I did:
- First I created a «private app» under may account and took its token, this is how they do now as API keys are going to be deprecated soon.
For now while I test I allowed all possibles scopes in this app.
I took the number of the account from the URL https://app-eu1.hubspot.com/private-apps/NUMBER (8 digit number)
I tried some endpoints and here might be a mistake, from all documentation it’s not obvious which endpoint to take in my case. For now I use this (took it from documentation) var url = 'https://api.hubapi.com/marketing/v3/marketing-events/attendance/NUMBER//email-create';
Then goes my code in Google Apps Script:
//loads data to Hubspot
function loadData(email,eventName,startDateTime,timeEvent,type,eventOrganizer,subscriberState) {
var url = 'https://api.hubapi.com/marketing/v3/marketing-events/attendance/NUMBER//email-create';
var body = {
"email": email,
"eventName": eventName,
"startDateTime": startDateTime,
"timeEvent": timeEvent,
"type": type,
"eventOrganizer": eventOrganizer,
"subscriberState":subscriberState
}
var option = {
"muteHttpExceptions" :true,
"method":"POST",
'payload': body,
"headers": {
"authorization": ’TOKEN’,
"content-type": "application/json"
}
}
var response = UrlFetchApp.fetch(url, option);
}
Please advise what is wrong here.
From
I need to create marketing events (like webinar data) in Hubspot taking data from cells in Google Sheets
and your showing request body, when I saw your provided document, it seems that the endpoint isPOST /marketing/v3/marketing-events/events
which is notPOST /marketing/v3/marketing-events/attendance/{externalEventId}/{subscriberState}/email-create
. It seems that your endpoint is forIf you wanted to use "Marketing Events", from your provided official document, I found a sample curl command as follows.
When this is converted to Google Apps Script, how about modifying your script as follows?
From:
To:
And also,
From:
To:
Note:
If you are required to use your currently showing endpoint of
var url = 'https://api.hubapi.com/marketing/v3/marketing-events/attendance/NUMBER//email-create';
, it is required to modify your request body as follows. Please be careful about this.References: