# Pulling data using Hubspot API in python

**URL:** <https://community.hubspot.com/t/pulling-data-using-hubspot-api-in-python/75561>\
**Category:** CRM\
**Tags:** crm, content\
**Created:** [February 20, 2023, 1:34pm UTC](https://community.hubspot.com/t/pulling-data-using-hubspot-api-in-python/75561 "2023-02-20T13:34:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Louraine](https://avatars.discourse-cdn.com/v4/letter/l/b9bd4f/32.png) [@Louraine](https://community.hubspot.com/u/Louraine)\
**Post date:** [February 20, 2023, 1:34pm UTC](https://community.hubspot.com/t/pulling-data-using-hubspot-api-in-python/75561/1 "2023-02-20T13:34:57Z")

</div>

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](https://d2qpr2jzcazej7.cloudfront.net/original/3X/a/c/ac19df8ac8260a19f0e6109aa31a068eaf9f96f3.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!

---

<div class="post-metadata">

**Author:** ![himanshurauthan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/himanshurauthan/32/53076_2.png) [@himanshurauthan](https://community.hubspot.com/u/himanshurauthan)\
**Post date:** [February 21, 2023, 8:03am UTC](https://community.hubspot.com/t/pulling-data-using-hubspot-api-in-python/75561/2 "2023-02-21T08:03:22Z")

</div>

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:

```lia-code-sample
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:

```lia-code-sample
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
