[SalesForce] How to get organization’s namespace prefix or at least ALL namespace prefixes including org through any API

How can I get organization's namespace prefix through API?

This solution doesn't match because it's not supposed that I know anything about org classes.

I understand that I can query ApexClasses through Tooling API, than create set and get all namespace prefixes BUT in that case I have to query also ApexTriggers, ApexPages and everything that can have namespace prefix.

Is there any better solution?

Best Answer

The DescribeMetadataResult from the Metadata API provides this in the organizationNamespace field.

There is an Apex wrapper for the Metadata API up on Github: https://github.com/financialforcedev/apex-mdapi that should give you access to the data you need (https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls#L238)

Related Topic