Authentication credentials not found "INVALID_AUTHENTICATION"

I’m receiving an ‘’ error when trying to update a company using Private App credentials.

I’ve looked through similar discussions and havent found anything that relates to my issue.

Im using the following to import company data to my application, which is working fine:

const hubspotHeaders = {
 headers: {
 'Authorization': `Bearer ${process.env.HBSSANDBXAPPK}`,
 'Content-Type': 'application/json'
 }
}; 

const fetchData = (url) => {
 return axios.get(url, hubspotHeaders).then(response => {
 console.log(response.data)
 })
 .catch(function (error) {
 console.log(error)
 });
};
fetchData(`https://api.hubapi.com/crm/v4/objects/companies?${hapikeyParam}`);

However, when I change the API endpoint and request to ‘patch’, I receive the error:

const hubspotHeaders = {
 headers: {
 'Authorization': `Bearer ${process.env.HBSSANDBXAPPK}`,
 'Content-Type': 'application/json'
 }
}; 
const properties = {
 "seo_revenue": 0
};

const putData = (url) => {
 return axios.patch(url, properties, { hubspotHeaders }).then(response => {
 console.log(response.data)
 })
 .catch(function (error) {
 console.log(error)
 });
};
putData(`https://api.hubapi.com/crm/v4/objects/companies/01010101010101`);

“message: 'Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at Accounts Dashboard | HubSpot

Am I missing something that PATCH requests require? Seems strange that the GET requests works but the PATCH request fails with an error.
Any information regarding this issue would be much appreciated, thank you.

Hi, @ROMG :waving_hand: Thanks for reaching out. I have a few questions to help the community better understand the issue and the steps you’ve already taken:

  • Have you already tried a simplified test? For example, can you make the same PATCH request using your Private App the Python example directly from the endpoints tab for this endpoint? — Associations API
  • Do you get the same error when trying a similar PATCH request from the Company API endpoints? Instead of the Associations endpoints your example used? PATCH/crm/v3/objects/companies/{companyId}

Thanks for the additional information!

Best,

Jaycee

Sorry for the late reply, we had multiple issues with this issues trying to post or patch with Node.js using Hubspot endpoints that we just wrote it in PHP. Not sure why it works with PHP and not Node.js but might want to look into that as there are multiple community tickets around this issue.