2
votes

I am able to create a defect using their XML REST API based on example found here: https://rally1.rallydev.com/slm/doc/webservice/rest_xml.jsp

However, I'm not able to do the same using jquery with their JSON api: This is how I submit a PUT in order to create a defect:

    var defectData = JSON.stringify(
            {
                Description: 'bla bla bla bla',
                Name: 'This is the defect name',
                Priority: 'None',
                ReleaseNote: 'false',
                Severity: 'Major Problem',
                State: 'Open',
                Owner: "https://<rallysite>/slm/webservice/1.28/user/<myuserid>.js"
                }
             );

    $.ajax({
          url: "https://<rallysite>/slm/webservice/1.28/defect/create",
          type: 'PUT',
          mimeType: 'application/javascript',
          data: { 'Defect': defectData },
          dataType: 'json',
          username: "<myusername>",
          password: "<mypassword>",
          success: function(data){
              console.log(data);
            }
        });

I don't see the PUT request being submitted through firebug on firefox or through dev tools in IE. I don't see any errors either. I tried doing a simple GET request to query my projects in Rally, and that works ok.

Not sure what I'm doing wrong, would appreciate help. Thanks!

2
If you are requesting data from a different domain you will run into issues with regular AJAX requests, you'll need to do a JSONP request for cross-domain requests: `$.ajax({dataType : 'jsonp'});Jasper
Note how he said he already had GET working, so I don't think that's it.Stefan Kendall

2 Answers

1
votes

Right from the jQuery docs:

typeString
Default: 'GET'
The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.

You might not be able to hit any PUT or DELETE endpoints at all, especially if you need to support IE.

0
votes

Also you may find the Rally App SDK a useful tool for accessing data from Rally's Rest Api.

The SDK was created using Dojo as it's underlying framework but could easily be used with JQuery. The AppSDK is tested on all major browsers and provides a simplified interface for interacting with Rally data.