CRM

Louraine
Teilnehmer/-in

Pulling data using Hubspot API in python

Hi Team,

I am trying to GET data from notes object in hubspot using python but I am getting authentication error. Please see below code and error:

 

Louraine_1-1676899968392.png

 

I believe the API KEY has been replaced by access token? Is that correct? but the error is related to API KEY. Would really appreciate your help on this! Thank you so much!

0 Upvotes
1 Antwort
himanshurauthan
Vordenker/-in | Elite Partner
Vordenker/-in | Elite Partner

Pulling data using Hubspot API in python

Hello @Louraine 

You need to pass the headers object as the second argument to axios.post, not as part of the data object. So your code should look like this:

const publishTable = async auth => {
  return await axios.post(
    `${HUBDB_API}/${HUBDB_TABLE_ID}/draft/publish`,
    {},
    {
      headers: {
        "Accept": "application/json",
        'Content-Type' : 'application/json',
        'Authorization' : `Bearer ${BIAPIKEY}`
      }
    }
  );
}


Then, the draft/publish endpoint is not a valid endpoint in the HubDB API. Instead, you should use the draft/push-live endpoint to publish a draft version of a table. So your code should look like this:

const publishTable = async auth => {
  return await axios.post(
    `${HUBDB_API}/${HUBDB_TABLE_ID}/draft/push-live`,
    {},
    {
      headers: {
        "Accept": "application/json",
        'Content-Type' : 'application/json',
        'Authorization' : `Bearer ${BIAPIKEY}`
      }
    }
  );
}



Make sure you have the necessary permissions and access to perform the publish action. Also, ensure that you have provided the correct HUBDB_API, HUBDB_TABLE_ID, and BIAPIKEY values.

Thanks & Regards
Himanshu Rauthan

Digital Marketing & Inbound Expert In Growth Hacking Technology