Layer7 API Management

Expand all | Collapse all

How do I update a WebLink field using the C# API Toolkit

  • 1.  How do I update a WebLink field using the C# API Toolkit

    Posted 02-12-2018 05:01 PM

    Does anyone know how to update a WebLink type field using the C# .Net API Toolkit?  I am trying the following code but it doesn't update the field - even though the code gets no errors.  Note, workItem is an HierarchicalRequirement. I am iterating through a query result. I have 3 Web Link fields, ParentFeature, ParentInitiative and ParentTheme that I am trying to populate.

     

    DynamicJsonObject workItem = enumerator.Current;

    DoubleObjID = workItem["ObjectID"];
    ObjID = DoubleObjID.ToString();
    NoUpdates = 1;
    try
    {
    DynamicJsonObject parent = workItem["Feature"];
    DynamicJsonObject updateTemplate = new DynamicJsonObject();
    if(parent != null)
    {
    updateTemplate["c_ParentFeature.DisplayString"] = parent["_refObjectName"];
    updateTemplate["c_ParentFeature.LinkID"] = parent["FormattedID"];
    DynamicJsonObject parentObj = rallyAPI.GetByReference(parent["_ref"], "FormattedID", "Parent");
    if (parentObj != null)
    {
    DynamicJsonObject initiative = parentObj["Parent"];
    if (initiative != null)
    {
    updateTemplate["c_ParentInitiative.DisplayString"] = initiative["_refObjectName"];
    updateTemplate["c_ParentInitiative.LinkID"] = initiative["FormattedID"];
    parentObj = rallyAPI.GetByReference(initiative["_ref"], "FormattedID", "Parent");
    if (parentObj != null)
    {
    DynamicJsonObject theme = parentObj["Parent"];
    if(theme != null)
    {
    updateTemplate["c_ParentTheme.DisplayString"] = theme["_refObjectName"];
    updateTemplate["c_ParentTheme.LinkID"] = theme["FormattedID"];

    }
    }
    }
    }
    OperationResult updateResult = rallyAPI.Update(WorkItemType, ObjID, updateTemplate);
    if (updateResult.Success == true)
    {
    WriteLog("Success", DateTime.Now, HierarchyField, workItem["FormattedID"], workItem["Project"]._refObjectName);
    }
    else
    {
    WriteLog("Error", DateTime.Now, "Update Failed", workItem["FormattedID"], workItem["Project"]._refObjectName);
    }

    }

    }
    catch (Exception Ex)
    {
    WriteLog("Fatal Error", DateTime.Now, Ex.ToString(), workItem["FormattedID"], workItem["Project"]._refObjectName);
    throw new Exception("Fatal Error Encountered.");
    }



  • 2.  Re: How do I update a WebLink field using the C# API Toolkit

    Posted 12-07-2018 01:06 AM

    Good evening,

     

    Please let let us know what product you are using. This community is for the CA API Gateway and the question you have seems to be related not to that technology.

     

     

    Sincerely,

     

    Stephen Hughes

    Broadcom Support