6

I am trying to open and save a Component through Core Service.

I am using SDL Tridion 2011 SP1.

I have written some code segment like this.

ComponentData c = client.Read("tcm:30-53172", new ReadOptions()) as ComponentData;
Console.WriteLine("component");
FullVersionInfo itemInfo = null;
itemInfo = (FullVersionInfo)c.VersionInfo;
if (itemInfo.LockType.Value != LockType.CheckedOut)
{
    client.CheckOut("tcm:30-53172", true, new ReadOptions());
    Console.WriteLine("Checked out");
}

client.Save(c, null);
Console.WriteLine("Saved");
client.CheckIn("tcm:30-53172", new ReadOptions());

This program just opens and updates the Component (Save and Close).

I am getting following exception message.

Unable to find http://acaf/azba:Metadata.

But when I do the same action using Tridion UI, it is accepting. I am not getting any error message.

Actually there are no mandatory metadata fields in the schema. Even if I save and close the component from Tridion UI, I do not find any Metadata element in the item xml of the component. I do not want to change any value in the component. I just wanted to save and close the component through the core service.

I am unable to figure out the error message. Could some one help me to make this work.

  • Please mention in which line of your CoreService client this operation is failing, also include the stack trace from event log. These info might help to narrow down the issue. – Likhan Oct 15 '13 at 11:15
9

You are not getting this error when you use the User Interface because it will won't allow you save the component if all the required information is not present. In this case the Core Services is telling you that the metadata has not been provided, you will need to set it in the Metadata property.

component.Metadata = "<Metadata xmlns=\"http://acaf/azba\"></Metadata>"
| improve this answer | |
  • Actually there are no mandatory metadata fields in the schema. Even if I save and close the component from Tridion UI, I do not find any Metadata element in the item xml of the component. As per your code, if there is already some metadata present in component that will be overridden right. I do not want to do that. I just wanted to save and close the component through the core service. Can you please help me in that? – Patan Oct 15 '13 at 7:32
  • 1
    Even if the Metadata is not mandatory you must provide an empty <Metadata> element. – Eric Huiza Oct 15 '13 at 11:04
4

This error is due to an inconsistency between your Schema and the Component. The issue is most likely that you added/modified/removed some metadata fields in your Schema, but have not filled in values in those fields in your Component.

Alternatively, you might have changed the namespace of the Schema (in the Schema source tab). And now the Component, still using the old namespace, it incompatible with your Schema namespace. Looking at the error you got, this is most likely what happened.

To fix it:

  • clear your browser cache
  • open the Component in the GUI (Tridion should detect the new namespace and prompt you for it)
  • make a change in your Component (usually adding a space at the end of your Component Name field is enough)
  • Save and Close the Component

If that won't fix it, try also editing the Source XML of your Component and checking the right namespace is in place for the fields.

| improve this answer | |
  • Thank you for the response. I have checked the schema and cleared the cache there is no problem with the name space. The name space is same as in the component. I unable to do this by program. Its strange that save and close action is not happening from core service – Patan Oct 15 '13 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.