Skip to content

Instantly share code, notes, and snippets.

@sammyteahan
Last active August 29, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sammyteahan/b1a12ade3a91c6de4ff5255095b9512d to your computer and use it in GitHub Desktop.
Save sammyteahan/b1a12ade3a91c6de4ff5255095b9512d to your computer and use it in GitHub Desktop.
Multipart form upload with requests
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