By my reading of the docs, it should be possible to create a new SObject by POSTing to /tooling/SObjects/EntityDefinition
, but I haven't made it work. Here's an example (the result of some trial-and-error, not all of which I have a record of), which I POSTed to /services/data/v34.0/tooling/sobjects/EntityDefinition
:
{
"Fullname" : "New_Object__c",
"Metadata" : {
"label" : "New Object",
"pluralLabel" : "New Objects"
}
}
This returns the error:
[ {
"message" : "Must specify a nameField of type Text or AutoNumber",
"errorCode" : "FIELD_INTEGRITY_EXCEPTION",
"fields" : [ ]
} ]
So then I tried:
{
"Fullname" : "New_Object__c",
"Metadata" : {
"label" : "New Object",
"pluralLabel" : "New Objects"
},
"nameField" : {
"DeveloperName" : "name",
"DataType" : "AutoNumber"
}
}
which returns the error:
[ {
"message" : "No such column 'nameField' on sobject of type EntityDefinition",
"errorCode" : "INVALID_FIELD"
} ]
Is it possible to create an SObject in this manner? I'd rather use Tooling API than Metadata API, as I'd like to stick to using REST.
Update: per the suggestion, I've moved nameField into the metadata hash like so:
{
"Fullname": "New_sObject__c",
"Metadata": {
"label": "New Object",
"pluralLabel": "New_Objects",
"sharingModel": "ReadWrite",
"deploymentStatus": "Deployed",
"nameField": {
"label": "qwerty",
"type": "Text",
"fullName": "asdfgh"
}
}
}
Which results in:
[ {
"message" : "insufficient access rights on cross-reference id",
"errorCode" : "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY",
"fields" : [ ]
} ]
Confusing, as I'm not referencing any ids. I also tried "fullName" : "name"
thinking that might be required.