These examples use a variety of python libraries.
For HTTP GET/POST requests, there are two that seem to work:
- urllib2 / json - working for basic GET requests
- requests - works for GET and POST requests
To install these, simply use the following command (on Linux. Windows How-To coming soon):
pip install requests
pip install json
More information about the Requests library can be found here: Python Request Quickstart Guide
-
For POST requests, it seems you need to format the request a specific way.
This is an example of a request that should work, given a valid iSENSE URL:
import json url = 'http://rsense-dev.cs.uml.edu/api/v1/projects/744/jsonDataUpload' payload = {'FIELDS': '[DATA, DATA, DATA]'} headers = {'content-type': 'application/json'} r = requests.post(url, data=json.dumps(payload), headers=headers)
The above code is based off of the following page: Python Requests JSON content
-
To get the fields for an iSENSE project, go to the following URL:
http://rsense-dev.cs.uml.edu/api/v1/projects/PROJECT_ID
(Replace PROJECT_ID with the ID of the project you want to use.)