function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mpiercempierce 

Metadata API errors: Must specify a type attribute value for the metadata element

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<SessionHeader xmlns="http://soap.sforce.com/2006/04/metadata">
<sessionId>...</sessionId>
</SessionHeader>
<CallOptions xmlns="http://soap.sforce.com/2006/04/metadata">
<client>...</client>
</CallOptions>
</S:Header>
<S:Body>
<create xmlns="http://soap.sforce.com/2006/04/metadata">
<metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Folder">
<fullName>testFolderFullName</fullName>
<accessType>Public</accessType>
<name>testFolderName</name>
</metadata>
</create>
</S:Body>
</S:Envelope>

 

When submitting the above XML, the server responds with a 500 and the following error:

 

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Client</faultcode>
<faultstring>Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

 

 

However, the following xml gets a 200 back (and actually does create the metadata object).

 

 

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Header>
<SessionHeader xmlns="http://soap.sforce.com/2006/04/metadata">
<sessionId>...</sessionId>
</SessionHeader>
<CallOptions xmlns="http://soap.sforce.com/2006/04/metadata">
<client>...</client>
</CallOptions>
</S:Header>
<S:Body>
<create xmlns="http://soap.sforce.com/2006/04/metadata">
<metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CustomField">
<fullName>Lead.foobar__c</fullName>
<label>foo label</label>
<length>28</length>
<type>Text</type>
</metadata>
</create>
</S:Body>
</S:Envelope>

 

 

 

Both requests have the "type" attribute on the "metadata" element in the correct namespace. Any idea why the second works while the first doesn't? (The second does have a "type" sub-element, but that's a property of CustomField specifically.)
Best Answer chosen by Admin (Salesforce Developers) 
mpiercempierce

Figured it out. The issue is not that the type attribute is missing; the problem is that Folder is not allowed as a type. (It would be nice if the error message was more useful...)

Specifically, you need to use a sub-type of Folder, e.g. DocumentFolder.

All Answers

mpiercempierce

Figured it out. The issue is not that the type attribute is missing; the problem is that Folder is not allowed as a type. (It would be nice if the error message was more useful...)

Specifically, you need to use a sub-type of Folder, e.g. DocumentFolder.

This was selected as the best answer
Apex LearnerApex Learner

is there any way to edit picklist value through metadat API . 

I am current testing meta data API via SOAP ui and till now I am able to add picklist values .

but can not edit any perticuler picklist value 

 

eg . object : lead 

       field : number__c

  type : picklist

 

values : 1 , 2

 

any methode i cn edit 1 to 11  ??

 

sfdcdev8sfdcdev8
Hi mpierce,
 
I am facing an issue when I try to update picklist values through metadata  API from SoapUI.
 
My Request is :
 
   <soapenv:Header>
    <met:CallOptions>
         <met:client></met:client>
      </met:CallOptions>
      <met:SessionHeader>
         <met:sessionId>-----</met:sessionId>
      </met:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <met:update>
         <!--Zero or more repetitions:-->
         <met:UpdateMetadata>
            <met:currentName>Account.test_field2__c</met:currentName>
            <met:metadata>
               <!--Optional:-->
               <met:fullName>Account.test_field2__c</met:fullName>
                <met:label>test field2</met:label>
    <met:picklist>
             <met:picklistValues>
        <met:fullName>five</met:fullName>
             </met:picklistValues>
        <met:sorted>false</met:sorted>
  </met:picklist>
        <met:type>Picklist</met:type>
    </met:metadata>
         </met:UpdateMetadata>
      </met:update>
   </soapenv:Body>
</soapenv:Envelope>
 
Error:
----------
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>
 
One more thing I am not sure what should be the value in the <met:client></met:client>
 
Please suggest.