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

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.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?

  • Hello,

    You can resolve this issue by adding the following line to your code:

    fieldDict.Add("req_document_type", "8DF7037346A64816B8BBD8700AFCFE15");

    This error is coming from the onBeforeAdd server event on the re_Requirement ItemType which is expecting this property to exist. 


    Christopher Gillis

    Aras Labs Software Engineer

  • Thanx! That worked. Can you please explain what this property is and why is it necessary? Also, is there a documentation which mentions a list of such properties that are needed to create an Item of any ItemType ?

  • Also I noticed one thing that this field in the ItemTypes table already has the default value set as "8DF7037346A64816B8BBD8700AFCFE15", so why do I need to add this value ?

  • 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.