How to set custom WebLink field value when submitting defect to Rally api?

I created a custom weblink box for a defect in Rally. And I would like to use the Rally api to submit a new defect with a custom feed field value corresponding to Rally.

Unfortunately the weblink instance requires a LinkID and DisplayString value, I don't know how to initiate a weblink instance to set the defect field.

I also tried setting DynamicJsonObject which is supported in Rally api for this field, but it still fails.

Failsafe screenshot enter image description here

Please, help!


I tried to submit a defect with a sample code like below:

        var api = new RallyRestApi("<myusername>", "<mypassword>", "");

        var defect = new DynamicJsonObject();
        defect["Name"] = "Sample Defect";
        defect["Description"] = "Test posting defect with weblink type field";
        defect["Project"] = "";
        defect["SubmittedBy"] = "";
        defect["ScheduleState"] = "In-Progress";
        defect["State"] = "Open";
        defect["Severity"] = "Major Problem";
        defect["Priority"] = "High Attention";
        defect["CustWebLink"] = new DynamicJsonObject(new Dictionary<string, object> 
            {"DisplayString", "abc"},
            {"LinkID", "123"}

        CreateResult creationResult = api.Create("defect", defect);


And now the defect can be sent to the rally, but it doesn't matter to CustWebLink. Upon investigation, I see that the CustWebLink field was ignored when serializing the posting request.

  Rally.RestApi Post Response: {"CreateResult": {"_rallyAPIMajor": "1", "_rallyAPIMinor": "29", "Errors": [], "Warnings": ["Ignored JSON element defect.CustWebLink during processing of this request."],.....}



source to share

1 answer

It's relatively simple, you just need to create a separate DynamicJsonObject for the Weblink and assign values ​​for the LinkID and DisplayString attributes to it. Then assign the Weblink object as the field for the defect. Here's a simple example:

    //Set our Workspace and Project scopings

    String workspaceRef = "/workspace/5912034914";
    String projectRef = "/project/5912035004";

    DynamicJsonObject myDefect = new DynamicJsonObject();
    DynamicJsonObject myWeblink = new DynamicJsonObject();

    // Populate the Weblink
    myWeblink["LinkID"] = "123456";
    myWeblink["DisplayString"] = "External Image Link";

    // Populate the Defect
    myDefect["Name"] = "My Defect";
    myDefect["Priority"] = "Normal";
    myDefect["Workspace"] = workspaceRef;
    myDefect["Project"] = projectRef;
    myDefect["zWeblinkField"] = myWeblink;

    CreateResult createDefect = restApi.Create("Defect", myDefect);




All Articles