Web Services
You can retrieve and store data in your ProjectPipe projects using web services. Our web services api follows the REST style, which means that you do queries and make changes by sending http GETs and POSTs, respectively. You verify that api calls succeeded by checking the http status code - 200 is good and 404 is an error. All output is in the JSON format, which is a simple, cross-platform data representation format with library support available for all major languages.
Below are sample URLs for project test.test:
- /test.test/svc/task - query the task table
- /test.test/svc/task/1 - read task with id of 1
- /test.test/svc/task/add - add a new task
- /test.test/svc/task/1/edit - edit task with id of 1
- /test.test/svc/task/1/delete - delete task with id of 1
One of the great things about REST apis is that you can use any http client to use the api. For example, you can use the curl command to query for tasks:
Below is a Python snippet to do the same thing:
theurl = ‘http://hosted.projectpipe.com/test.test/svc/task′
username = ‘userid’
password = ‘password’
encoding = base64.encodestring(’%s:%s’ % (username, password))[:-1]
req = urllib2.Request(theurl, headers={’Authorization’: ‘Basic %s’ % encoding})
out = urllib2.urlopen(req).read()
pprint.pprint(simplejson.loads(out))
If there is an error then the urlopen().read() will throw an exception, that's the great thing about using http status codes.