Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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