2

I'm working with the Metadata API, and I'm attempting to simply create a Custom Object.

I'm using the Python zeep package, and it generates for me this XML:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Header>
    <ns0:SessionHeader xmlns:ns0="http://soap.sforce.com/2006/04/metadata">
      <sessionId>...</sessionId>
    </ns0:SessionHeader>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:createMetadata xmlns:ns0="http://soap.sforce.com/2006/04/metadata">
      <ns0:metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:Metadata">
        <ns0:fullName>SomeCustomObject</ns0:fullName>
      </ns0:metadata>
    </ns0:createMetadata>
  </soap-env:Body>
</soap-env:Envelope>

But when I send the query, it gives me this error:

Fault: Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}metadata element

I was getting that error earlier, and thought it was because I was missing xsi:type on the metadata element, since that attribute wasn't there yet. But as you can see, I fixed it such that the generated XML now has that attribute, but it still gives me the error.

Can someone explain this error to me? I'm not sure if the issue is in Python where that XML gets generated, or if that's the correct XML, and a later step is having an issue.

Thanks!

3

The request body is alright except for the xsi:type="ns0:Metadata" attribute.

Instead of the abstract ns0:Metadata, that should read ns0:CustomObject for example:

<soap-env:Header>
  <ns0:SessionHeader xmlns:ns0="http://soap.sforce.com/2006/04/metadata">
      <sessionId>...</sessionId>
    </ns0:SessionHeader>
  </soap-env:Header>
  <soap-env:Body>
    <ns0:createMetadata xmlns:ns0="http://soap.sforce.com/2006/04/metadata">
      <ns0:metadata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:CustomObject">
        <ns0:fullName>SomeCustomObject__c</ns0:fullName>
      </ns0:metadata>
    </ns0:createMetadata>
  </soap-env:Body>
</soap-env:Envelope>

Then it will parse and start validating the custom object parameters, eg:

Invalid fullName, must end in a custom suffix ( for ex. __c )

And so on...

Must specify a non-empty label for the CustomObject

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.