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

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
  • 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.

Join the Discussion

    There are currently no comments.

    59 + = 60