Polls OAuth REST API Example performed with the Virtuoso OAuth Testing Tool
The following example demonstrates adding and getting poll by the ODS REST APIs poll.new and poll.get using the OAuth Test Tool.
Full list of the ODS REST APIs for ODS Polls you can find here.
- Go to http://demo.openlinksw.com/ods
- Log in as user demo with password demo
- Go to Settings->OAuth Keys
- Copy the Token value for an Polls instance or create such in not existing.
For ex.: cb0c9e0335fa088f7c779b0fec826b5a6af120c4
- Go to http://demo.openlinksw.com/ods/oauth_test.vsp
- In the shown form enter for:
- Server: http://demo.openlinksw.com/ods/api
- Consumer Key: cb0c9e0335fa088f7c779b0fec826b5a6af120c4
- API method: poll.new
- API parameters:
inst_id=61&name=MyPoll
- An easy way to get the instance id is using the ODS Framework Controller instance.get.id:
$ curl -i "http://demo.openlinksw.com/ods/api/instance.get.id?user_name=demo&password_hash=4627dhe23cb53f522eag32e09gs7fceaw2c523449bdfdf&instanceName=mypolls"
HTTP/1.1 200 OK
Server: Virtuoso/06.03.3131 (Linux) x86_64-generic-linux-glibc25-64 VDB
Connection: Keep-Alive
Date: Sun, 05 Feb 2012 21:01:20 GMT
Accept-Ranges: bytes
Content-Type: text/xml; charset="UTF-8"
Content-Length: 58
<result>
<code>61</code>
<message>Success</message>
</result>
- You can also get the instance id using the ODS Ubiquity commands sequence:
ods-host http://demo.openlinksw.com/ods
ods-set-mode sid
ods-authenticate-user demo password demo
ods-get-instance-id mypolls
- Select for Query options: "Generate URI and Submit".
- Click the "Execute" button.
- Enter the password for user demo and click the "Login" button.
- In the shown authorization form click the "Authorize" button.
- As result will be shown the generated URI and the output message of executing the ODS REST API.
In our case, the id of the new created poll will be: 1012
- Now lets get the data for the created poll.
In the form enter:
- API method: poll.get
- API parameters: poll_id=1012
- Select for Query options: "Generate URI and Submit".
- Click the "Execute" button.
- As result in the "Response Body" text-area will be shown the retrieved details for the poll with the given above id.
Related
CategoryPolls CategoryODS