Unable to download files from a specific folder in box.com using python with JWT authentication
My Code:
from boxsdk import JWTAuth, Client
sdk = JWTAuth.from_settings_file('config.json')
client = Client(sdk)
service_account = client.user().get()
print('Service Account user ID is {0}'.format(service_account.id))
user=client.user(user_id = service_account)
# root_folder = client.root_folder().get()
root_folder = client.folder(folder_id='131510140491')
items = root_folder.get_items()
for item in items:
print('{0} {1} is named "{2}"'.format(item.type.capitalize(), item.id, item.name))
with open(item.name, 'wb') as open_file:
client.file(item.id).download_to(open_file)
print('downloaded')
open_file.close()
Following errors I am getting:
"GET https://api.box.com/2.0/folders/131510140491/items?offset=0" 404 324
{'Date': 'Sat, 13 Feb 2021 13:05:15 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Strict-Transport-Security': 'max-age=31536000', 'Cache-Control': 'no-cache, no-store', 'Content-Encoding': 'gzip', 'BOX-REQUEST-ID': '0554da0191ae5fa3f5a35c02557bdaaea'}
{'code': '---ound',
'context_info': {'errors': [{'message': "Invalid value 'd_131510140491'. "
"'folder' with value 'd_131510140491' "
'not found',
'name': 'folder',
'reason': 'invalid_parameter'}]},
'help_url': 'http://developers.box.com/docs/#errors',
'message': 'Not Found',
'request_id': '4d574lgnm7l5tbzb',
'status': 404,
'type': 'error'}
Please sign in to leave a comment.
Comments
2 comments