How To Query the VersionOne REST Data API for User Stories in JSFiddle with jQuery, JSON, HTTP GET, and 9 Lines of Code
Developing Custom VersionOne Apps 101 Series Guide
Last time, in Understand How and Why REST APIs Work — Demonstrated with the VersionOne Data API, you looked at the VersionOne REST API in action, using only your browser’s address bar.
Now you’ll write code. At last.
In this article, you will
- Get familiar with the JSFiddle online editor
- Use jQuery.ajax to issue a GET HTTP request to the VersionOne Data API
The first version of the protocol had only one method, namely GET, which would request a page from a server. The response from the server was always an HTML page. — HTTP article on Wikipedia
What you’ll need
- Google Chrome. While it should work, I have not tested this in other browsers, so if you run into any snags, please let me know in the comments
Get familiar with JSFiddle and jQuery’s $.ajax function
- Open a brand new window or tab in Chrome and navigate to http://www.JSFiddle.net
- From the left side, under
Choose Framework. It should have
onLoadpreselected (leave it this way)
- Select the most recent version of
- On the right, you’ll see four panels:
[gist id=4689842 file=gistfile1.js]
Expected JSON Output
[gist id=4689842 file=gistfile2.json]
Try the live JSFiddle
Try it again with XML as the result format
For illustration purposes, now just paste in the following code into JSFiddle and run it. This time, you’ll get the raw XML format because we do not pass the
Accept: "halsjon" request header. XML is the default data format the VersionOne Data API supports.
[gist id=4689842 file=gistfile3.js]
Try the Live JSFiddle
That was easy enough. Now, let’s see how to change the data in How To Update a User Story with the VersionOne REST Data API in JSFiddle with jQuery, JSON, HTTP POST, and 20 Lines of Code.