API migration V3

Hi, I need to migrate Hubdb v1 to v3.

Below is the v1 code, can some one help me upgrade to v3 please.

import requests

url = ‘https://api.hubapi.com/hubdb/api/v1/tables/
#apikey = ‘NOPE’
headers = {
‘Authorization’: ‘Bearer pat-na1-NOPE’
}
table_id = ‘5090722’
#post_url = url + table_id + ‘/import?hapikey=’ + apikey
post_url = url + table_id + ‘/import’

import_config = ‘{“resetTable”:true,“skipRows”:0,“format”:“csv”,’\
‘“nameSourceColumn”:15,“pathSourceColumn”:40,“columnMappings”:[{“source”:15,“target”:23},’ \
‘{“source”:9,“target”:3},{“source”:3,“target”:40},{“source”:18,“target”:5},’ \
‘{“source”:19,“target”:6},’ \
‘{“source”:17,“target”:7},{“source”:35,“target”:12},{“source”:32,“target”:9},{“source”:36,’ \
‘“target”:20}, {“source”:33,“target”:10},{“source”:34,“target”:11},’ \
‘{“source”:23,“target”:13},{“source”:16,“target”:14},’ \
‘{“source”:6,“target”:16},{“source”:5,“target”:17},{“source”:38,“target”:19},’ \
‘{“source”:31,“target”:41},{“source”:37,“target”:42},{“source”:8,“target”:36},’ \
‘{“source”:9,“target”:37},{“source”:10,“target”:38},{“source”:11,“target”:39},’ \
‘{“source”:2,“target”:40},{“source”:12,“target”:43},{“source”:20,“target”:44},’ \
‘{“source”:13,“target”:45},{“source”:21,“target”:46},{“source”:22,“target”:47},’ \
‘{“source”:25,“target”:48},{“source”:26,“target”:49},{“source”:26,“target”:50},’ \
‘{“source”:28,“target”:51},{“source”:41,“target”:54},{“source”:4,“target”:55},{“source”:3,“target”:4},{“source”:24,“target”:52},{“source”:14,“target”:18},’ \
‘{“source”:39,“target”:2}]}’

files = {
‘config’: (None, import_config, ‘application/json’),
‘file’: (None, open(‘data.csv’, ‘rb’), ‘text/csv’)
}

#r = requests.post(post_url, files=files)
r = requests.post(post_url, files=files,headers=headers)

print(r)
print(r.content)

Hey, @Mm87 :waving_hand: Thanks for your post. Please be careful to never share your authentication tokens. I’ve removed them from this post. And you should cycle them out ASAP.

To your request, can you clarify which specific endpoint you are using? CMS API | HubDB

For example, is it either of?

  • GET/cms/v3/hubdb/tables
  • POST/cms/v3/hubdb/tables

Thank you! — Jaycee

Hi @Jaycee_Lewis , thanks for your message. I’m using Post method.