Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some fixes to the API example scripts

  • Loading branch information...
commit 876d8e132e05957f49d9bd4e044b13975cbca9c2 1 parent 9edba24
@priteau priteau authored
View
5 example_scripts/domain_create.py
@@ -2,6 +2,7 @@
import os
import sys
+
import json
import requests
@@ -25,5 +26,5 @@
}
r = requests.post("%s/domains" % api_url, data=json.dumps(new_domain), auth=(user_id, token))
-if r.status_code != 200:
- sys.exit("Error: %s" % r.text)
+if r.status_code != 201:
+ sys.exit("Error %d: %s" % (r.status_code, r.text))
View
5 example_scripts/domain_list.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
import os
+import sys
+
import requests
user_id = os.environ['USER_ID']
@@ -8,6 +10,9 @@
api_url = os.environ.get('PHANTOM_URL', "https://phantom.nimbusproject.org/api/dev")
r = requests.get("%s/domains" % api_url, auth=(user_id, token))
+if r.status_code != 200:
+ sys.exit("Request failed with status code %d" % r.status_code)
+
all_domains = r.json()
for domain in all_domains:
Please sign in to comment.
Something went wrong with that request. Please try again.