Having trouble creating a milestone in a specific project

78 Views Asked by At

I'm trying to create a milestone in a specific work space. The milestone is getting created in a different work space.

here is the code snippet

            m["Name"] = "xx";
            m["TargetDate"] = "2017-06-01";              
            result = restApi.Create(workspaceRef, "Milestone", m);
            if(result.Success)
            {
                LogWriter.LogWrite(string.Format("The specific milestone {0} has been created!", name));
                m = restApi.GetByReference(result.Reference, "FormattedID");
                LogWriter.LogWrite(string.Format("The specific milestone has been created with formattedId {0}", m["FormattedID"]));
                Console.WriteLine(m["FormattedID"]);
            }
            else
            {
                LogWriter.LogWrite(string.Format("Error creating milestone {0}, Exception: {1}", name, result.Errors[0].ToString()));
            }

Any thoughts or insights as to why this is happening?

Thanks, Vasanthi

1

There are 1 best solutions below

0
On

I think this is a bit of a bug in the .NET toolkit. You should be able to work around it though, by setting the Workspace attribute of the Milestone rather than using the overload of Create that takes a workspaceRef:

m["Workspace"] = workspaceRef;
result = restApi.create("Milestone", m);

I've never found the overloads of all the CRUD methods that take a workspaceRef all that useful myself.