+ Start a Discussion
Danny ODanny O 

How to get organization ID from REST API

How can I get the organization ID of a user through the REST API that's based on his user ID?


The following SOQL query produces "sObject type 'Organization' is not supported."


"select id from Organization where user_id = '{user_id}'"




Jia HuJia Hu
Id aid = Userinfo.getOrganizationId();
System.debug(' ---- ' + aid );

First make a GET request for the resources from a url like this:




The returned JSON object will include a field called identity which contains a URL with this format  https://login.salesforce.com/id/organizationID/userID


You can then query that URL for detailed info on the user and organization, see here: http://help.salesforce.com/help/doc/en/remoteaccess_using_openid.htm