Last active
August 29, 2017 19:47
-
-
Save sammyteahan/b1a12ade3a91c6de4ff5255095b9512d to your computer and use it in GitHub Desktop.
Multipart form upload with requests
This file contains 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 os | |
import sys | |
import requests | |
from pprint import pprint | |
PROJECTS_URL = os.environ.get('PROJECTS_URL') | |
MANIFEST_PATH = os.environ.get('MANIFEST_PATH') | |
TEMPLATE_ID = os.environ.get('TEMPLATE_ID') | |
# pylint: disable=C0111 | |
def create_project(): | |
files = {'manifest': open(MANIFEST_PATH, 'rb')} | |
data = {'label': 'Project Label', 'template': TEMPLATE_ID } | |
response = requests.post(PROJECTS_URL, files=files, data=data) | |
return response | |
def main(): | |
r = create_project() | |
print(pprint(r.text)) | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment