Skip to content

Instantly share code, notes, and snippets.

@yosemitebandit
Created November 8, 2011 18:54
Show Gist options
  • Save yosemitebandit/1348724 to your computer and use it in GitHub Desktop.
Save yosemitebandit/1348724 to your computer and use it in GitHub Desktop.
api testing
#! /usr/bin/env python
'''
api_test.py
'''
import requests
engine = 'pv66-lab'
auth = ('admin', 'redwood')
'''
request = { # results in error: badRequestFraming
"protocolVersion": "1"
, "schemaVersion": "1"
, "requestType": "get"
, "requestData": "null"
}
'''
'''
request = { # results in error: badRequestFraming
"protocolVersion": "1"
, "schemaVersion": "1"
, "requestType": "get"
, "requestData": None
}
'''
request = {
"protocolVersion": "1"
, "schemaVersion": "1"
, "requestType": "get"
, "requestData": {
"rootLocation": [
{
"name": "All Locations"
, "childLocation": [
{
"name": "Training Area"
}
]
}
]
}
}
print 'requesting..'
endpoint = 'https://%s/cgi-bin/xApi.cgi' % engine
r = requests.post(endpoint, auth=auth, data=request)
print 'saving..'
f = open('out.json', 'w')
f.write(r.content)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment