Created
February 23, 2016 07:15
-
-
Save bmiles/e0c51b232a2cbecd8fb5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 requests | |
import json | |
# Use autoprotocol-python package to generate autoprotocol | |
import autoprotocol as ap | |
# Example protocol | |
p = ap.Protocol() | |
con = p.ref("name", id=None, cont_type="96-flat", storage=None, discard=True) | |
p.cover(con) | |
p.spin(con, "500:g", "60:second") | |
# End protocol | |
headers = {"X-User-Email": '', | |
"X-User-Token": '', # Regular-mode API key | |
"Content-Type": "application/json", | |
"Accept": "application/json"} | |
url = '' | |
# POST Body, note statement of test mode boolean | |
body = json.dumps( | |
{"title": "myrun", "protocol": p.as_dict(), "test_mode": True}) | |
response = requests.post(url, body, headers=headers) | |
if response.status_code == 201: | |
print(response) | |
run_id = response.json()['id'] | |
print run_id | |
else: | |
print "Error creating run:" | |
print json.dumps(response.json(), indent=2) | |
error = response.json()['protocol'][0]['context']['instruction'] | |
print instructions[error] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment