# Different Responses Fix when using "/settings/v3/users/" Endpoint

**URL:** <https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594>\
**Category:** APIs & Integrations\
**Tags:** crm\
**Created:** [June 16, 2025, 5:44pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594 "2025-06-16T17:44:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_Kulas](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Drew\_Kulas](https://community.hubspot.com/u/Drew_Kulas)\
**Post date:** [June 16, 2025, 5:44pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/1 "2025-06-16T17:44:16Z")

</div>

I am using the `/settings/v3/users/’ endpoint. I am using this to build custom code for an activty tracker that triggers when certain activites have occured, such as Emails, Calls, Meetings, and Deals. I have set up Teams in HubSpot based on the users roles. The principle is to use this activity tracker to keep communication with clients through only Account Executives. I am using the hubspot\_owner\_id. Here is the function I am using as well as the error message from the failed response when testing in HubSpot:

const Hubspot = require(‘@hubspot/api-client’);

// Fetch the teams for a given user (owner)  
async function fetchUserTeams(hubspotClient, userId) {  
try {  
console.log(`Fetching teams for userId: ${userId}`);  
const resp = await hubspotClient.apiRequest({  
method: ‘GET’,  
path: `/settings/v3/users/${userId}`,  
});  
const json = await resp.json();  
console.log(‘Full API response:’, json);

// Extract primary team ID  
const primaryTeamId = json.primaryTeamId ? [json.primaryTeamId] : [];  
const teamIds = […primaryTeamId];

console.log(`Found teamIds for user ${userId}:`, teamIds);  
return teamIds;  
} catch (error) {  
console.log(`Failed to fetch teams for userId: ${userId}. Error:`, error);  
return [];  
}  
}

// Fetch owner details (optional, for logging/display)  
async function fetchOwner(hubspotClient, ownerId) {  
if (!ownerId) return { firstName: ‘Unknown’, lastName: ‘Owner’ };  
const resp = await hubspotClient.apiRequest({  
method: ‘GET’,  
path: `/crm/v3/owners/${ownerId}`,  
});  
const json = await resp.json();  
return { firstName: json.firstName, lastName: json.lastName };  
}

exports.main = async (event, callback) =\> {  
// Log the full event for debugging  
console.log(‘Full event:’, JSON.stringify(event, null, 2));

// Use only hs\_object\_id as the contact ID  
const contactId = event.inputFields.hs\_object\_id;  
console.log(‘Using contactId (hs\_object\_id):’, contactId);

if (!contactId) {  
console.log(‘No hs\_object\_id found in inputFields!’);  
callback({ outputFields: { error: ‘No hs\_object\_id found in inputFields!’ } });  
return;  
}

const hubspotClient = new Hubspot.Client({ accessToken: process.env.PrivateAccessKey });

// Get the contact’s owner ID  
const contact = await hubspotClient.crm.contacts.basicApi.getById(contactId, [‘hubspot\_owner\_id’]);  
const ownerId = contact.properties.hubspot\_owner\_id;  
console.log(‘Contact ownerId (hubspot\_owner\_id):’, ownerId);  
const owner = await fetchOwner(hubspotClient, ownerId);

// Fetch and log the primary team for the owner  
const primaryTeamId = await fetchUserTeams(hubspotClient, ownerId);

// Log the result  
console.log(‘Primary Team ID for owner:’, primaryTeamId);

// Return results in outputFields  
callback({ outputFields: {  
primaryTeamId,  
ownerId,  
ownerName: `${owner.firstName} ${owner.lastName}`  
}});  
};

Error Response:

```auto
2025-06-16T17:43:15.185Z	INFO	Failed to fetch teams for userId: 458921319. Error: FetchError: invalid json response body at https://api.hubapi.com/settings/v3/users/458921319 reason: Unexpected token '<', "<html>
<he"... is not valid JSON
 at /opt/nodejs/node_modules/node-fetch/lib/index.js:273:32
 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 at async fetchUserTeams (/var/task/file.js:11:18)
 at async exports.main (/var/task/file.js:60:25) {
 type: 'invalid-json'
}

```

| hs\_execution\_state | SUCCESS |
| primaryTeamIdNot defined in output field | [] |
| ownerIdNot defined in output field | 458921319 |
| ownerNameNot defined in output field |

Why might this be occuring?

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [June 17, 2025, 10:21am UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/2 "2025-06-17T10:21:23Z")

</div>

Hi [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), I hope that you are well!  
Thanks for reaching out to the HubSpot Community!  
I’d love to put you in touch with our Top Experts: Hi [@sylvain\_tirreau](https://community.hubspot.com/t5/user/viewprofilepage/user-id/601366), @Anton and [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811) do you have suggestions to help [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), please?  
Have a great day and thanks so much in advance for your help!  
Bérangère

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [July 1, 2025, 2:43pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/3 "2025-07-01T14:43:58Z")

</div>

Hi [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), I hope that you are well!  
I wanted to check on you, do you still need help?  
If yes, let me check with our Top Experts to see if they have ideas for you:  
Hi @Teun, @stefen and @Indra do you have suggestions to help [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), please?  
Have a lovely day and thanks so much in advance for your valuable contributions!  
Bérangère

---

<div class="post-metadata">

**Author:** ![Drew\_Kulas](https://avatars.discourse-cdn.com/v4/letter/d/22d042/32.png) [@Drew\_Kulas](https://community.hubspot.com/u/Drew_Kulas)\
**Post date:** [July 1, 2025, 3:27pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/4 "2025-07-01T15:27:51Z")

</div>

Yes I do still need hel.

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [July 15, 2025, 11:09am UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/5 "2025-07-15T11:09:40Z")

</div>

Hi [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), ok thanks for confirming!  
Let’s check with other Experts and see if we can get you some help:  
Hi @WesQ, @mangelet and @Gonzalo do you have some ideas to help [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), please?  
Have a great day and thanks so much for your help!  
Bérangère

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [July 29, 2025, 2:21pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/6 "2025-07-29T14:21:38Z")

</div>

Hi [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), I hope that you are well!  
For information, here are some documentation about the endpoint you mentioned that might help you:  
- [User provisioning](https://developers.hubspot.com/docs/reference/api/settings/users/user-provisioning)  
- [Users](https://developers.hubspot.com/docs/guides/api/settings/users/user-details)  
- [Response: json() method](https://developer.mozilla.org/en-US/docs/Web/API/Response/json)

It seems that your code expected JSON from [https://api.hubapi.com/settings/v3/users/458921319](https://api.hubapi.com/settings/v3/users/458921319), but instead received HTML.  
The error shows the response began with \<html\>, which is typical when receiving an error page (e.g., 404 Not Found, 401 Unauthorized, or 500 Internal Server Error), not valid API JSON.  
Can you confirm that you are indeed trying to fetch teams for the user via this endpoint?  
Not all endpoints return team data directly, make sure you’re calling the right one.  
Also, the API endpoints require a valid OAuth token or API key. Can you please double-check your headers?  
If your token is expired or invalid, HubSpot returns an HTML error page, which causes this parsing issue.  
Hi [@sylvain\_tirreau](https://community.hubspot.com/t5/user/viewprofilepage/user-id/601366), @MatthewShepherd, @alyssamwilie and @Kevin-C do you have other suggestions to help [@Drew\_Kulas](https://community.hubspot.com/t5/user/viewprofilepage/user-id/898796), please?  
Have a lovely day and thanks so much in advance!  
Bérangère

---

<div class="post-metadata">

**Author:** ![sylvain\_tirreau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sylvain_tirreau/32/67408_2.png) [@sylvain\_tirreau](https://community.hubspot.com/u/sylvain_tirreau)\
**Post date:** [July 30, 2025, 4:11pm UTC](https://community.hubspot.com/t/different-responses-fix-when-using-settings-v3-users-endpoint/134594/7 "2025-07-30T16:11:05Z")

</div>

Hi,

hubspot\_owner\_id returns the ID of an Owner (id field). The actual UserID expected by the Settings API is found in the userId property of the OwnersAPI response; if you pass the ownerId as is, Hubspot often returns an HTML login page (hence the “\<html\>…”).  
I would try this in your place:

```lia-code-sample
const owner = await ownersApi.getById(ownerId)
idToUse = owner.userId
requestUrl = `/settings/v3/users/${idToUse}`

```
