I'm accessing the Salesforce REST API from a Java-based web service and would like to get a list of all fields in the Account table that are marked nillable: false. I know I can make a request like this:


But that returns way more information than I want since we have a lot of fields on that table. I want to know if there's a way to query that metadata so I only pull down the small amount I care about, which is the names of the fields that can't be null.

  • I was going to suggest you try using the CustomField from the Tooling API where TableEnumOrId = Account. However, I don't think you can filter using the Metadata field. Commented Apr 19, 2015 at 21:33

1 Answer 1


As you've probably seen, the metadata API doesn't allow you to filter on nillability (or anything similar). If you're attempting to reduce the size of the return, the first consideration would be if doing that will really make a big difference to you over, say, pre-querying in the background for object metadata and filtering those lists accordingly. That would probably be a one-time hit at app startup or similar, so it may or may not be acceptable.

You could create an Apex REST service that used the Apex native metadata API to find all the nillable fields, and then just return those over the exposed REST endpoint. Wouldn't be tons of work, but it may be overkill. I'm not aware of any out-of-the-box API way to only retrieve an object's custom fields based on field attributes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .