I am learning how to use the Tridion 2011 Core Service API and am trying to create a new folder containing a new Person
schema with a single Name
field.
When I run the following code I get the error FaultException : Namespace URI must have a value
. If I uncomment the personSchemaFields.Namespa...
it works fine but I'm pretty sure that this isn't the correct solution as I get errors later on when trying to use the schema (cannot find uuid:[GUID]:Person
).
using (var client = new Tridion2011CoreService.CoreServiceClient())
{
var newFolder = client.GetDefaultData(ItemType.Folder, "tcm:4-160721-2");
newFolder.Title = DateTime.Now.Ticks.ToString();
newFolder = client.Create(newFolder, new ReadOptions());
var personSchemaDataFields = new List<ItemFieldDefinitionData>();
var personSchemaFieldName = new SingleLineTextFieldDefinitionData();
personSchemaFieldName.Name = "Name";
personSchemaFieldName.Description = "Name";
personSchemaDataFields.Add(personSchemaFieldName);
var personSchemaFields = new SchemaFieldsData();
//personSchemaFields.NamespaceUri = "uuid:" + Guid.NewGuid().ToString();
personSchemaFields.RootElementName = "Person";
personSchemaFields.Fields = personSchemaDataFields.ToArray();
var personSchema = (SchemaData)client.GetDefaultData(ItemType.Schema, newFolder.Id);
personSchema.Title = "Person";
personSchema.Description = "Person";
personSchema.RootElementName = "Person";
personSchema.Xsd = client.ConvertSchemaFieldsToXsd(personSchemaFields).ToString();
// The next line generates the following error. "FaultException : Namespace URI must have a value."
personSchema = (SchemaData)client.Create(personSchema, new ReadOptions());
}
Could anyone help?