Skip to content

Instantly share code, notes, and snippets.

@pellepim
Last active March 14, 2019 09:57
Show Gist options
  • Save pellepim/f8c84568a4030100851791e86beaf622 to your computer and use it in GitHub Desktop.
Save pellepim/f8c84568a4030100851791e86beaf622 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import requests
from requests_oauthlib import OAuth1 as OAuth
import urllib
import json
CLIENT_KEY = u'REDACTED'
CLIENT_SECRET = u'REDACTED'
BASE_URL = u'https://api.projectplace.com/'
access_token_key = u'REDACTED'
access_token_secret = u'REDACTED'
oauth = OAuth(CLIENT_KEY, client_secret=CLIENT_SECRET, resource_owner_key=access_token_key,
resource_owner_secret=access_token_secret)
r = requests.post(url=BASE_URL + '2/documents/1069865/upload',
files={'file': open('hej-fil-med-åäö.txt', 'rb')},
auth=oauth)
try:
print(json.dumps(r.json(), sort_keys=True, indent=4, separators=(',', ': ')))
print(r.request.body)
print(r.request.headers)
except:
print(r.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment