Upload file with OAuth token Error 500 + fail


#1

Following the exact Python example from the documentation (https://developers.hubspot.com/docs/methods/files/post_files),
with an OAuth token instead of HAPI key, fails.

import requests
bear = 'Bearer CILi0IbrKxICCgUY4OPvASDjyzgopa4DMhkAQvuSEwHI_kR7bp7pFrSLCcV7cL0v39zs’
headers = {‘Authorization’:bear, ‘Content-Type’:‘multipart/form-data’,‘User-Agent’: ‘node-hubspot’}
files = {‘files’: open(‘logo.png’,‘rb’)}
r = requests.post(‘http://api.hubapi.com/filemanager/api/v2/files’,data={‘folder_paths’:'foo’},files=files,headers=headers)
print r.text
{“status”:“error”,“message”:“internal error”,“correlationId”:“726af6e7-3b39-4ffc-b0a5-ec0296af28a3”,“requestId”:“e2d54b43d3e3f088f64dab12dc6f92c0”}

t = requests.post(‘http://api.hubapi.com/filemanager/api/v2/files?hapikey=018ab7ed-ac03-431c-b38b-afba6b220aaa’, data={‘folder_paths’:‘foo’},files=files)
print t.text
{“objects”:[{“id”:5352395857,“portal_id”:3928544,“name”:“logo”,“size”:0,“height”:null,“width”:null,“encoding”:null,“type”:“IMG”,“extension”:“png”,“cloud_key”:“hubfs/3928544/foo/logo.png”,“s3_url”:“http://cdn1.hubspot.com/hubfs/3928544/foo/logo.png",“friendly_url”:“https://cdn2.hubspot.net/hubfs/3928544/foo/logo.png”,“alt_key”:“hubfs/3928544/foo/logo”,“alt_key_hash”:“0eb30bb2f1e025ff2d6d80714d69846b”,“title”:“logo”,“meta”:{“url_scheme”:“SIMPLIFIED”,“allows_anonymous_access”:true},“created”:1506188081722,“updated”:1506188081797,“deleted_at”:0,“folder_id”:5352395855,“hidden”:false,“cloud_key_hash”:“420f7e0dd00d716491a977e796173013”,“archived”:false,“url”:“https://cdn2.hubspot.net/hubfs/3928544/foo/logo.png”,“alt_url”:"http://cdn2.hubspot.net/hubfs/3928544/foo/logo.png”}]}

The same token works for /filemanager/api/v2/folders,
and the app being tested has Content privs.

Can you confirm that this API call works with OAuth tokens?
TKs