Created
October 26, 2018 12:15
-
-
Save mraarif/d54fa746cf8ca457d79dcdda3c30f84d to your computer and use it in GitHub Desktop.
python How to upload file, multipart Post request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def post_multipart(): | |
try: | |
user = {'email': '[email protected]', 'first_name': 'test user 1','password': 'samplepassword'} | |
image = {'image': open('path/to/file', 'rb')} | |
requests.post('/api/url', files=image, data=user) | |
except Exception as ex: | |
print('user creation failed') | |
print(str(ex)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment