hariszhr
hariszhr

Reputation: 409

Updating a testset in Rally using java Rally Rest API

QueryRequest allreleases = new QueryRequest("release");
    allreleases.setQueryFilter(new QueryFilter("project", "=", project_ref));
    QueryResponse resp = restApi.query(allreleases);
    if(resp.wasSuccessful()){

        System.out.println("list of all the release numbers available...");
        for(JsonElement result : resp.getResults()){
            System.out.println(result.getAsJsonObject().get("Name").getAsString());
            if(result.getAsJsonObject().get("_refObjectName").getAsString().equals("release 1")){
                System.out.println("Sdsadsad");
                temp_ref = result.getAsJsonObject().get("_ref").getAsString();
                System.out.println(temp_ref);
                }
            }
        }

    JsonObject updatt = new JsonObject();
    updatt.addProperty("release", temp_ref);

    UpdateRequest req1 = new UpdateRequest(testset_ref, updatt);
    UpdateResponse resp1 = restApi.update(req1);

    if(resp1.wasSuccessful()){
        System.out.println("release added to testset");

    }

I am using this piece of code to make an update to an already created testset (adding a "release"). The code runs but the release field doesn't get updated. I don't know what am I doing wrong. Any hints?

Thanks.

Upvotes: 0

Views: 798

Answers (1)

Kyle Morse
Kyle Morse

Reputation: 8410

Field names in the WSAPI are case sensitive, so you likely need "Release" instead of "release" in order for the update to work correctly. Inspecting the warnings collection on the response using the code above would have shown a message that "release" was an unknown field and it was ignored.

Correct:

updatt.addProperty("Release", temp_ref);

Upvotes: 1

Related Questions