Skip to main content
Enterprise Agile Planning Image

This post is from the CollabNet VersionOne blog and has not been updated since the original publish date.

Last Updated Feb 07, 2013 — Enterprise Agile Planning expert

How To Query the VersionOne REST Data API for User Stories in JSFiddle with jQuery, JSON, HTTP GET, and 9 Lines of Code

Enterprise Agile Planning
Developing Custom VersionOne Apps 101 Series GuideLast 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
This exercise will take you through the first step toward our next goal of building a very rudimentary Story Editor using standard HTML and JavaScript. But first, we simply use GET. Remember Tim Berners/Lee's statement about the beginning of the web and how the HTTP protocol did just one thing well? Here it is again:
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
Our response will be a JSON document :) // JSON = JavaScript Object Notation, which is simple, structured data that the JavaScript language interpreter built/in to the browser understands.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

Let's use the handy and free online JavaScript / HTML / CSS editor JSFiddle to query the VersionOne REST API:
  • 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 onLoad preselected (leave it this way)
  • Select the most recent version of jQuery
  • On the right, you'll see four panels: HTML, JavaScript, CSS, and Result
  • Type the following 9 lines of code into the JavaScript panel, then press Run
[gist id=4689842 file=gistfile1.js]

Expected JSON Output

After running it, you should see something like the following. The data is returned in the JavaScript Object Notation format (JSON). We'll explain more about JSON later, but just know that this data is also valid JavaScript executable code, and that is what makes JSON data very natural for web browsers to handle and parse. [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

Next up

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.

More from the Blog

View more
Apr 08, 2021

Making IT services more agile

Enterprise Agile Planning
The agile revolution completely transformed how we create digital prod ...
Read More
Feb 14, 2021

Reflecting on the 20th anniversary of the Agile Manifesto

Enterprise Agile Planning
Over the past 20 years, it’s been amazing to watch an idea from ...
Read More
Feb 08, 2021

How does agile apply to an entire organization?

Enterprise Agile Planning
Before we dive into the main subject of this blog post, it is importan ...
Read More
Feb 03, 2021

It took a pandemic to realize why digital transformation actually matters

Enterprise Agile Planning
Before anyone had ever heard of COVID-19, businesses across the globe ...
Read More
Contact Us