I am trying to write a Python script to test my iOS app's API server is running and functioning correctly. I have connected and authenticated with the server fine by logging in using the website credentials. The problem I am having is passing the 'uploaddata' payload into the 'r = requests.post' and getting it to successfully upload the file. The script doesn't return any errors through Terminal but doesn't upload the file.
Any help would be greatly appreciated.
Thanks
Will
import json
import requests
url = 'www.yoururl.com/login.php'
payload = {'email': 'email', 'password': 'password', 'submit': 'log in'}
r = requests.post(url, data = payload)
uploadurl = 'www.yoururl.com'
files = open('/Users/Will/Desktop/APITestDoc.doc', 'rb')
uploaddata = {"file": "APITestDoc.doc", "path": "/Users/Will/Desktop/APITestDoc.doc", "name": "APITestDoc.doc", "redirect": "/"}
headers = {'Content-Disposition': 'form-data'}
r = requests.post(url, data = json.dumps(uploaddata))

New Topic/Question
Reply



MultiQuote




|