Skip to content

Instantly share code, notes, and snippets.

@aim-up
Last active May 26, 2020 12:58
Show Gist options
  • Save aim-up/f4debd7bf0728e53fdbf43cbbad0505c to your computer and use it in GitHub Desktop.
Save aim-up/f4debd7bf0728e53fdbf43cbbad0505c to your computer and use it in GitHub Desktop.
SmartFile API Client test for #33131
#!/usr/bin/python3
import os
import pprint
from smartfile import BasicClient
api_key = os.environ['SMARTFILE_API_KEY']
api_password = os.environ['SMARTFILE_API_PASSWORD']
api = BasicClient(api_key, api_password)
# pprint.pprint(api.get('/ping'))
f = open('./tmp/foo.xlsx', 'rb')
pprint.pprint(api.post('/path/data/test_files/', file=('sfpyclient.was.here.xlsx', f)))
###############
# $ python3 sfpyclient.py
# Traceback (most recent call last):
# File "sfpyclient.py", line 10, in <module>
# pprint.pprint(api.post('/path/data/test_files/', file=('sfpyclient.was.here.xlsx', f)))
# File "/Users/jdunn/Library/Python/3.7/lib/python/site-packages/smartfile/__init__.py", line 131, in post
# return self._request('post', endpoint, id=id, data=kwargs)
# File "/Users/jdunn/Library/Python/3.7/lib/python/site-packages/smartfile/__init__.py", line 110, in _request
# return self._do_request(request, url, **kwargs)
# File "/Users/jdunn/Library/Python/3.7/lib/python/site-packages/smartfile/__init__.py", line 207, in _do_request
# return super(BasicClient, self)._do_request(*args, **kwargs)
# File "/Users/jdunn/Library/Python/3.7/lib/python/site-packages/smartfile/__init__.py", line 58, in _do_request
# raise ResponseError(response)
# smartfile.errors.ResponseError: Response 500: Server error; check response for errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment