Created
May 17, 2017 19:26
-
-
Save frennkie/ba88ddaf898cafd7d4d5c93f4ed20711 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import requests | |
USERNAME = "admin2" | |
PASSWORD = "not-very-secret" | |
APIURL = "http://127.0.0.1:8080/api/v3" # no trailing slash | |
PROJECT_NAME = "otrs" | |
# create project | |
r = requests.post("{}/project/".format(APIURL), data={"name": PROJECT_NAME}, auth=(USERNAME, PASSWORD)) | |
if r.status_code not in [200, 201, 202]: | |
raise Exception("something went wrong: {} ({})".format(r.text, r.status_code)) | |
# upload file to project | |
files = {'file': open('/tmp/foobar2/dummy4.txt', 'rb')} | |
r = requests.post("{}/project/{}/malware/upload/".format(APIURL, PROJECT_NAME), files=files, auth=(USERNAME, PASSWORD)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment