Oct 25, 2022 4:51 PM
Hello,
I'm trying to create a timeline event on a contact. The event has a custom token, `ownerId` with a mapping to a custom property on Contacts named `owner`.
The custom property is a HubSpot user field type.
So the idea is then when I create an action in the contact activity timeline and pass an `ownerId`, the contact will automatically get assigned to the owner.
But the issue is that when I make the request to:
POST /crm/v3/timeline/events
with body (abbreviated for concision) :
{
...
"tokens": { "ownerId": 1234 }
}
I get the following error:
validationResults":[{"isValid":false,"message":"1234 was not a valid owner ID","error":"INVALID_OWNER_ID","name":"owner"}]
Note: The ID isn't actually 1234, it's an owner ID that I got from querying the /crm/v3/owners endpoint, so I know it's a valid owner ID.
Please let me know if you see anything that I'm doing wrong, or if there's a better way to assign owners to contacts via timeline events
Solved! Go to Solution.
Oct 27, 2022 10:29 AM
@chrisworqflowAha! Figured it out 🙂
I was querying the /owners endpoint, but using the developer API key, which returns a different owner ID than if I query the same endpoint using OAuth.
So if I authenticate with OAuth instead, I find the owner with the correct ID which allows me to pass this ID in when creating a Contact timeline event, and have it auto-assign the owner to the contact. Hooray!!
Oct 25, 2022 5:16 PM
Hey @JF_dev, thanks for sharing! I don't have a ton of HubSpot development experience, but I'm wondering if this has anything to do with the fact that you're mapping to a custom contact property instead of the default "Contact owner" property. Do you get the same result if you use "Contact owner" instead?
| ||||||||||||
| ||||||||||||
Create Your Own Free Signature |
Oct 25, 2022 5:36 PM
Hi @jolle,
There's no "Contact owner" property mapping in the UI dropdown menu, but I did some digging and it looks like the field is called `hubspot_owner_id` .
If I set my custom token to map to that field (it lets me "create" a field with that name), I see the same behavior.
I've tried setting the data type to either String or Integer, and in both cases I still get the INVALID_OWNER_ID error back 😕
Oct 25, 2022 5:43 PM
Thanks for the quick response! I'm going to tap into some awesome HubSpot Community members.
@danmoyle @Jnix284 @chrisworqflow any idea what could be the issue here?
| ||||||||||||
| ||||||||||||
Create Your Own Free Signature |
Oct 26, 2022 8:10 AM
Thanks for thinking of me @jolle. My dev chops are light, but I'll share this with my colleague @Kevin-C and our dev team. Kevin may have insight for you @JF_dev .
Did this post help solve your problem? You can help others find answers when you accept a reply as a solution. (I also appreciate it!)
|
![]() |
Oct 25, 2022 7:11 PM
Oct 26, 2022 2:23 AM
Oct 26, 2022 9:58 AM
@jolle @danmoyle @JF_dev I believe this is because the property isn't considered a string because contact owner is a user-property (Internal ID), meaning that it updates with the internal users in the platform.
Are you mapping the token based upon the internal IDs of the HubSpot users?
Go to Settings->Properties->Contact Properties and search and click on the Contact Owner Property. On that screen, it will list your contact owners (users) and their internal value (user ID.)
|
Oct 26, 2022 4:41 PM
@chrisworqflowThank you for pointing me to the Contact Owner Property!! I did some more digging and can now clearly state what the problem is.
The property being a string is not the actual issue, it's that the IDs listed for the contact owners don't match the ones returned by the API.
Once I used the "internal value" listed in the UI, it worked!
I was able to use ID `123456` as the value of my custom token `ownerId`.
This custom token has a Contact property mapping of `hubspot_owner_id`, so when I create a timeline event for a contact that doesn't have an owner, it automatically gets assigned to the owner matching that ID.
So the main issue here is, what _is_ id `123456`?? As far as I can tell it's not a User id nor an Owner id.
When I query the CRM Owners API, I find `John Doe` but its `id` and `userId` are different than the "Internal Value" ID above.
Is there any way for me to find this ID via any APIs?
Oct 26, 2022 4:43 PM
@JF_dev This article may help: https://legacydocs.hubspot.com/docs/methods/owners/get_owners
|
Oct 26, 2022 5:22 PM
I was previously querying the v3 endpoint: "/crm/v3/owners" and only getting back "id" and "userId"
The article you linked me is for the v2 endpoint: "/owners/v2/owners" which returns more stuff (portalId, remoteId, activeUserId) but unfortunately none of them match the "Internal Value" id from the UI, which is the only one that works 😞
Oct 26, 2022 6:52 PM
@JF_dev How about this one:
https://developers.hubspot.com/docs/api/crm/owners
|
Oct 27, 2022 10:29 AM
@chrisworqflowAha! Figured it out 🙂
I was querying the /owners endpoint, but using the developer API key, which returns a different owner ID than if I query the same endpoint using OAuth.
So if I authenticate with OAuth instead, I find the owner with the correct ID which allows me to pass this ID in when creating a Contact timeline event, and have it auto-assign the owner to the contact. Hooray!!