# -*- coding: utf-8 -*-
import requests
import os
import json

file = "./ConstructionSite"  # <1>
projectId = 1  # <2>
depositoryId = "Scenarios1"  # <3>
authKey = 'rn~YourAuthKey~'  # <4>
host = "https://localhost:8443"  # <5>

payload = {}
payload['projectId'] = projectId
payload['depositoryId'] = depositoryId
payload['attributes'] = {'Key1=Value1', 'LaneCount=2', 'StreetType=Lane'}  # <6>

headers = {'TestGuide-AuthKey': authKey}  # <7>

uploadFile = {'file': (os.path.basename(file), open(file, 'rb'))}
r = requests.post(u"{0}/api/artifact/artifacts".format(host),
                  params=payload, files=uploadFile, verify=True, headers=headers)

if r.status_code < 300:
    print("Upload successful.")
else:
    print("Upload error: {0} - {1}", r.status_code, r.content)
