I want to access the Standard "System Administrator" profile using MetadataService.cls (found here https://github.com/financialforcedev/apex-mdapi)
Therefore I tried this
MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.Profile profile
= ( MetadataService.Profile) service.readMetadata(
'Profile',
new String[] { 'System Administrator'}
).getRecords()[0];
Unfortunately profile is not populated by the readMetadata-method. It behaves exactly like a non-existing profile.
How the profile can be read?
Best Answer
The issue is the name of the profile.
Using exclipse downloading all profiles, I found that there is an "Admin" profile instead. Reading this the same way as described above, it works.