I am trying to create objects with the REST api, which works fine as long as I specify a value for each required field in the POST. The question is, how can I tell from the API which fields are required?
According to the API documentation, I should use Describe, like so:
/services/data/v30/sobjects/Account/describe/
When I do this, I get tons of metadata about the fields, but no indication as to which fields are required. I've compared required fields to optional fields and none of the metadata seems to indicated that the field is required.
Another SO thread suggested that "nillable" was equivalent to required, but that appears to be untrue. For example, Account.Name has nillable=true. I've also looked at custom objects with custom required fields, they can be nillable too. What am I missing here?
Best Answer
The way you are getting the field description is Ok:
If you check in the official doc you'll see
I've checked Account.Name and nillable seems to be Ok:
Also, I've tried two custom fields an the result are Ok:
Are you sure that your API response are getting the wrong value? Are you working with PersonAccounts?
Updated
In addition (By reading Jonathan answer) I notice, you could also check if the pageLayout using the same REST API:
You will get there the layouts for that object where will find the
layoutItem
object which contains therequire
attr.However, I think that you are trying to insert/update data through API and hence those security controls are expected to be omitted