Chris
Chris

Reputation: 899

New to Rally API, trying to add test case result

I've just begun working on the rally API. I want to create a new test case result but I keep getting an exception and dont know why. I think this is going to turn out to be something really dumb causing it, but I cant figure it out.

Heres my code:

public static void updateRally(){
    URL url
    RallyService service = null
    try{
        url = new URL("https://rally1.rallydev.com/slm/webservice/1.36/RallyService")
        service = (new RallyServiceServiceLocator()).getRallyService(url)
    } catch (MalformedURLException e){
        e.printStackTrace()
        throw new Exception("RallyWebServiceClient.main problem in creating the url")
    } catch (Exception e){
        e.printStackTrace()
        throw new Exception("RallyWebServiceClient.main problem in creating the service")
    }

    if (service == null){
        println("Error: Service is null")
        throw new Exception("RallyWebServiceClient.main service null...")
    }

    //Set authentication information on the service
    Stub stub = (Stub)service
    stub.setUsername("MyUsername")
    stub.setPassword("MyPassword")

    //Configure the service to maintain an HTTP session cookie
    stub.setMaintainSession(true)

    //Start calling methods on the service
    User user = (User)service.getCurrentUser()
    println(user.getDisplayName())

    TestCase testCase = new TestCase()
    testCase.setName("TC7571")

    TestCaseResult result = new TestCaseResult()
    result.setTestCase(testCase)
    result.setBuild("1.16.0-SNAPSHOT-6256")
    result.setDuration(1.0)
    result.setTester(user)
    result.setVerdict("Pass")

    CreateResult createResult = service.create(result)
}

I keep getting told theres an exception in the main thread with excit code 1. Its not getting past the line which reads User user = (User)service.getCurrentUser()

I was following a guide I found on the Rally website. I suspect the problem is the URL I am using. I've also tried the URL to the WSDL instead of whats above and get the same problem.

I appreciate any help, thanks.

Upvotes: 1

Views: 1339

Answers (1)

Kyle Morse
Kyle Morse

Reputation: 8400

We recommend new users try our REST api instead of SOAP:

http://developer.rallydev.com/help/java-toolkit-rally-rest-api

You should then be able to do something like this:

RallyRestApi restApi = new RallyRestApi(new URI("https://rally1.rallydev.com"), "[email protected]", "password");

JsonObject newTestCase = new JsonObject();
newTestCase.addProperty("Name", "Awesome Test");
CreateRequest createRequest = new CreateRequest("testcase", newTestCase);
CreateResponse createResponse = restApi.create(createRequest);

String newTestCaseRef = createResponse.getObject().get("_ref").getAsString();

Upvotes: 2

Related Questions