1
votes

I am trying to create a defect in Rally using code that looks something like that:

JsonObject newDefect = new JsonObject();

newDefect.addProperty("Workspace", workspaceRef);
newDefect.addProperty("Project", projectRef);

newDefect.addProperty("Name", d.name);
newDefect.addProperty("QCID", d.qcid);
newDefect.addProperty("My Product", d.product);
newDefect.addProperty("Owner", getUserReference(restApi, d.owner));
newDefect.addProperty("Submitted By", getUserReference(restApi, d.owner));

System.out.println("Creating defect: " + d.qcid + " - " + d.name);
CreateRequest createRequest = new CreateRequest("defect", newDefect);
CreateResponse createResponse = restApi.create(createRequest);

The JSON that is being sent is: {"Workspace":"https://rally1.rallydev.com/slm/webservice/v2.0/workspace/1234", "Project":"https://rally1.rallydev.com/slm/webservice/v2.0/project/1234", "QCID":1, "Name":"my name", "Description":"my desc", "Notes":"my notes", "Owner":"https://rally1.rallydev.com/slm/webservice/v2.0/user/1234", "State":"Closed", "Resolution":null, "My Product":"MyProduct", "Severity":"4 - Low", "Submitted By":"https://rally1.rallydev.com/slm/webservice/v2.0/user/1234", "Environment":"Development", "Found in Version":"8.0", "Target Build":"10.0", "Affected Customers":null}

I get these warnings from rally:
Ignored JSON element defect.QCID during processing of this request.
Ignored JSON element defect.My Product during processing of this request.
Ignored JSON element defect.Submitted By during processing of this request.
Ignored JSON element defect.Found in Version during processing of this request.
Ignored JSON element defect.Target Build during processing of this request.

I tried to pass the QCID as a string value ("QCID":"1") but the result is the same.

How do I troubleshoot this? how can i know why these fields are not populated?

One thing in common for almost all of these fields is that they have a space in the name of the field. QCID doesn't have a space, but it was originally created as 'QC ID', so it had a space.

Thanks

2
QCID has a numeric value, vs char string. I suspect the interface you're using requires keys without special chars (including blanks) and values that are text strings.Hot Licks

2 Answers

0
votes

Hot Licks is correct in that for Field Names whose Display Name contains spaces, you should omit the spaces when using them in WSAPI Since QCID no longer has a space that should be ok but all fields will need to be updated to not contain any spaces. i.e. 'SubmittedBy' not 'Submitted By'

Since QCID does not contain any spaces yet you are still getting an error I would verify that this field exists in the Workspace and Project your code is scoping to.

0
votes

For custom fields you'll need to prefix the names with c_. None of the field names should have spaces when you submit them.

So c_QCID, c_MyProduct, SubmittedBy, etc.

newDefect.addProperty("Name", d.name);
newDefect.addProperty("c_QCID", d.qcid);
newDefect.addProperty("c_MyProduct", d.product);
newDefect.addProperty("Owner", getUserReference(restApi, d.owner));
newDefect.addProperty("SubmittedBy", getUserReference(restApi, d.owner));

When in doubt simply do a query against that type and fetch the fields you are looking for. Or browse the web service docs- you should be able to see all your fields there.

https://rally1.rallydev.com/slm/doc/webservice/