"Root element is missing." XML Error when trying to add Requirement through .NET API

I am trying to add a Requirement through the .NET API. Here is my code:

//creating new connection

HttpServerConnection conn = IomFactory.CreateHttpServerConnection(serverUrl, dbName, username, password);
Innovator inn = IomFactory.CreateInnovator(conn);
conn.Login();

Item addItem = inn.newItem("re_Requirement", "add");
Dictionary<string, string> fieldDict = new Dictionary<string, string>();

//adding properties
fieldDict.Add("managed_by_id", "AD30A6D8D3B642F5A2AFED1A4B02BEFA");
fieldDict.Add("req_priority", "Critical");
fieldDict.Add("classification", "Test");
fieldDict.Add("owned_by_id", "AD30A6D8D3B642F5A2AFED1A4B02BEFA");
fieldDict.Add("req_risk", "Low");
fieldDict.Add("type", "Text");

foreach (KeyValuePair<string,string> field in fieldDict)
{
    addItem.setProperty(field.Key, field.Value);
}

Item result = addItem.apply();
Console.WriteLine(result);
Console.WriteLine(result.isError()); // returns true

When I run this program in Visual Studio, I get the following error:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="">schemas.xmlsoap.org/.../"><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af="">www.aras.com/.../faultcode><faultstring><![CDATA[Root element is missing.]]></faultstring><detail><af:legacy_detail><![CDATA[Root element is missing.]]></af:legacy_detail><af:exception message="Root element is missing." type="System.Xml.XmlException" /></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>

I am using Aras 11 SP15. Note that this has the Requirements Engineering feature only instead of the Requirements Management, hence the name of the item is re_Requirement. How to solve this issue?

Parents Reply Children
  • The new RE application is built off of the same framework that powers our Technical Documentation application. These kinds of ItemTypes require a schema in order to define what the format of the document should be. In RE 11.0R1, all of the requirements default to a particular schema specific to requirements. This property is not configurable by default.

    The reason it needs to be defined in your AML despite having a default value is that default values are not applied until after the onBeforeAdd server event has run. Because of this, the property still has a blank value in the onBeforeAdd server event which is causing the error you are seeing when a snippet of code attempts to access that value.

    Typically, you can see which properties on an ItemType are needed to create it by checking which properties have the Required flag set to true. However, this is a special case because the error is not being thrown by the standard add logic. It's instead being thrown in the onBeforeAdd server event. 

    I've filed an issue internally to report this behavior. It does make sense to not need to define this property in your AML because of the default value.

    Chris