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

I created a custom weblink box for a defect in Rally. And I would like to use the Rally rest.net 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 rest.net api for this field, but it still fails.

Failsafe screenshot enter image description here

Please, help!

Edited:

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

        var api = new RallyRestApi("<myusername>", "<mypassword>", "https://community.rallydev.com");

        var defect = new DynamicJsonObject();
        defect["Name"] = "Sample Defect";
        defect["Description"] = "Test posting defect with weblink type field";
        defect["Project"] = "https://trial.rallydev.com/slm/webservice/1.29/project/5839639589.js";
        defect["SubmittedBy"] = "https://trial.rallydev.com/slm/webservice/1.29/user/5797741589.js";
        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."],.....}

      

+3


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);

      

+3


source







All Articles