Developing Custom VersionOne Apps 101 Series Guide

In the last article, How To Query the VersionOne REST Data API for User Stories in JSFiddle with jQuery, JSON, HTTP GET, and 9 Lines of Code, we used HTTP GET, jQuery’s implicit HTTP method, to query a specific User Story. Now, let’s use a simple HTTP POST with jQuery to update the same story.

In this article, you will

  • Use the JSFiddle online editor
  • Use jQuery.ajax to issue an HTTP POST request to the VersionOne Data API to update a User Story

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.

Fire Up a New JSFiddle

  • Open a brand new window or tab in Chrome and navigate to
  • From the left side, under Choose Framework, leave onLoad preselected
  • Select the most recent version of jQuery
  • Type the following 20 lines of code into the JavaScript panel, then press Run
var url = "";
var headers = { Authorization: "Basic " + btoa("admin:admin"), Accept: "haljson" };
var storyDto = {
 Description: prompt("Enter a description", "Changing description at time of " + $.now()),
 Estimate: prompt("Enter an estimate of 1 to 5", "2")
var settings = {
 url: url,
 type: "POST",
 data: JSON.stringify(storyDto),
 dataType: "json",
 contentType: "haljson",
 headers: headers
$.ajax(settings).done(function(data) {
 beautifulJson = JSON.stringify(data, null, 4);
 $("body").html("<pre>" + beautifulJson + "</pre>");
}).fail(function(jqXHR) {

Expected JSON Output

After running it, you should see something like this:

    "Description": "Changing description at time of 1359615935655",
    "Estimate": "2",
    "_links": {
        "self": {
            "href": "/platformtest/rest-1.v1/Data/Story/1154/1609",
            "id": "Story:1154:1609"

Understand the jQuery $.ajax options

This time, we pass a few more settings to jQuery, such as the POST HTTP method, and, of course, a “stringified” DTO object with two properties that will overwrite those properties on the remote Story asset. The dataType and contentType options tell jQuery what the format coming back is, and the server what the incoming content format is, respectively. Note that “haljson” is itself simply JSON data, but the server formats it consistent the current proposed HAL+JSON standard format for hypermedia APIs. We’ll discuss that in later articles.

The the live JSFiddle

Next up

Let’s revisit querying and do some HTML rendering this time, shall we? Read How To Use jQuery to GET a User Story in JSON Format from the VersionOne REST Data API and Render it as HTML next.

Join the Discussion

    There are currently no comments.

    76 − = 69