I'm currently struggling in creating a ContactOwnerSharingRule via the Salesforce Metadata API.
I am using Ruby and the metaforce gem.
I am using the the create-method which calls out to the SOAP API. the call then looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://soap.sforce.com/2006/04/metadata" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://soap.sforce.com/2006/04/metadata">
<env:Header>
<ins0:SessionHeader>
<ins0:sessionId>sessionId</ins0:sessionId>
</ins0:SessionHeader>
</env:Header>
<env:Body>
<ins0:create>
<ins0:metadata xsi:type="ins0:ContactOwnerSharingRule">
<ins0:fullName>foo</ins0:fullName>
<tns:name>bar</tns:name>
<tns:contactAccessLevel>Edit</tns:contactAccessLevel>
<tns:sharedFrom>abc</tns:sharedFrom>
<tns:sharedTo>def</tns:sharedTo>
</ins0:metadata>
</ins0:create>
</env:Body>
</env:Envelope>
At this point it doesn't matter what I put into sharedFrom or sharedTo, because the error message is something else:
Required field is missing: Parent
I have not found a reference to a parent field in any documentation nor the Metadata WSDL file.
If I set the parent field to something, I get this error message:
Must specify a {http://www.w3.org/2001/XMLSchema-instance}type attribute value for the {http://soap.sforce.com/2006/04/metadata}parent element
So my question is:
Hast anyone ever created a SharingRule via the metadata API? And if so, how does the SOAP request look like?