I want to view the Metadata(RecordType, VF access, Apex class access,etc.) from Profile using Tooling API. My code looks similar to this

ToolingAPI toolingAPI = new ToolingAPI();
List<ToolingAPIWSDL.sObject_x> profileObject =    (List<ToolingAPIWSDL.sObject_x>)toolingAPI.query('Select Description, FullName,     Metadata From Profile Where FullName = \'Admin\'').records;
System.debug('Description' + profileObject.Description);
System.debug('FullName' + profileObject.FullName);
System.debug('Metadata' + profileObject.Metadata);
System.debug('RT' + profileObject.Metadata.ProfileRecordTypeVisibility);
System.debug('VF' + profileObject.Metadata.ProfileApexPageAccess );

By this code i can see in the debug description, fullname correctly stated, but metadata receive null values for all fields like ProfileRecordTypeVisibility, ProfileApexPageAccess, etc. Where could be the problem? How can I get any list for record types, apex classes, pages for any profile?

2 Answers 2


I do not have experience with the Tooling API querying Profiles but I know in the MetaData API you must specify the object as well as the profile to return object and field permissions. It appears to be the case that the Tooling API has the same issue.

An alternative (linked to below) is to simply query the permissions objects, as defined here: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_permissionset.htm

For example:

FROM ObjectPermissions
WHERE SobjectType = 'Merchandise__c'

For more information see this similar question: Tooling API - ProfileMetadata not being returned v32

  • 1
    But I want to list of Apex Classes, Pages and Record Types for particular profile that I choose.
    – Daniel
    Commented Oct 19, 2016 at 10:07

The data is coming back in the SOAP response. It will just be a matter of getting the backing Apex classes correct to deserialize the response.

toolingSoapSforceCom.SforceService toolingAPI = new toolingSoapSforceCom.SforceService();
toolingAPI.SessionHeader = new toolingSoapSforceCom.SessionHeader_element();
toolingAPI.SessionHeader.SessionId = UserInfo.getSessionId();
toolingAPI.endpoint_x = URL.getSalesforceBaseUrl().toExternalForm() + '/services/Soap/T/36.0';

toolingSoapSforceCom.sObject_x[] profileObjects =  toolingAPI.query('Select Description,  Metadata From Profile Where Id = \'00e70000000sye7AAA\'').records;
for(toolingSoapSforceCom.sObject_x profile : profileObjects) {


<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:tooling.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mns="urn:metadata.tooling.soap.sforce.com">
        <queryLocator xsi:nil="true" />
        <records xsi:type="Profile">
          <Id xsi:nil="true" />
            <!-- ... -->

Check your API version. Salesforce has been changing the namespaces in the recent couple of releases of the Tooling API. See Knowledge Article 206845 - Spring 15 - Tooling API changes

  • SessionId and endpoint is set in ToolingAPI.cls and I am using API version 36.0. When I debug Metadata they look like:
    – Daniel
    Commented Oct 20, 2016 at 6:43
  • MetadataMetadata:[recordTypeVisibilities=null, recordTypeVisibilities=null, recordTypeVisibilities_type_info=(recordTypeVisibilities, urn:metadata.tooling.soap.sforce.com, null, 0, -1, false), classAccesses=null, classAccesses_type_info=(classAccesses, urn:metadata.tooling.soap.sforce.com, null, 0, -1, false) ..... and the same for all fields
    – Daniel
    Commented Oct 20, 2016 at 6:46
  • Where did you get your ToolingAPI.cls from? Did you generate it? It should contain a class that represents the Metadata. Commented Oct 20, 2016 at 6:49
  • it was added from github github.com/afawcett/apex-toolingapi . It contains ToolingApi.cls, ToolingAPIWSDL, ToolingAPIWSDLMetadata, ToolingAPIWSDLMock, and test classes.
    – Daniel
    Commented Oct 20, 2016 at 8:19
  • I am sorry, we used API version of 29 for Tooling API, so i will probably try to get newer one and probably it will fix my issue. I will let you know.
    – Daniel
    Commented Oct 20, 2016 at 11:22

You must log in to answer this question.

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