Created
March 31, 2015 17:02
-
-
Save Sunil02kumar/6a57b219b845d5bf2062 to your computer and use it in GitHub Desktop.
Custom Object info using Tooling API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apex Code: | |
HttpRequest req = new HttpRequest(); | |
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID()); | |
req.setHeader('Content-Type', 'application/json'); | |
String domainUrl=URL.getSalesforceBaseUrl().toExternalForm(); | |
system.debug('********domainUrl:'+domainUrl); | |
req.setEndpoint(domainUrl+'/services/data/v28.0/tooling/query/?q=Select+id,DeveloperName,Sharingmodel,NamespacePrefix+from+CustomObject'); | |
req.setMethod('GET'); | |
Http h = new Http(); | |
HttpResponse res = h.send(req); | |
system.debug(res.getBody()); | |
Response will be in JSON and it will be in below format: | |
{ | |
"size": "123", | |
"totalSize": "123", | |
"done": "true", | |
"entityTypeName": "CustomEntityDefinition", | |
"records": [ | |
{ | |
"attributes": { | |
"type": "CustomObject", | |
"url": "/services/data/v28.0/tooling/sobjects/CustomObject/01I90000000oCnsEAE" | |
}, | |
"Id": "01I90000000oCnsEAE", | |
"DeveloperName": "Items", | |
"SharingModel": "Edit" | |
}, | |
{ | |
"attributes": { | |
"type": "CustomObject", | |
"url": "/services/data/v28.0/tooling/sobjects/CustomObject/01I90000001IxALEA0" | |
}, | |
"Id": "01I90000001IxALEA0", | |
"DeveloperName": "Mobile_App_Object_Fields", | |
"SharingModel": "ControlledByParent" | |
}, | |
{ | |
"attributes": { | |
"type": "CustomObject", | |
"url": "/services/data/v28.0/tooling/sobjects/CustomObject/01I90000000nzuGEAQ" | |
}, | |
"Id": "01I90000000nzuGEAQ", | |
"DeveloperName": "Salesforce_Access_Key", | |
"SharingModel": "Edit" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment