+ Start a Discussion

How to create a profile using metadata api through apex class

Hi all


    I just want to create the profile using meta data api, but there are some hurdels 


I am able to create custom object using metadata api the sample code for that is


public static void createObject()
MetadataService.MetadataPort service = createService();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'Test__c';
customObject.label = 'Test';
customObject.pluralLabel = 'Tests';
MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { customObject });


In the similar manner i want to create profile using meta data api, if any one has anty idea then please give me the code


Hey Abhishek,


I found the following article on accessing  Profiles using Metadata API:



Hope this helps!




Hi sonam 


    I have read that, but there are some confusion that how i can implement it, can u give an exmple of creating profile using apex metadata api




Abhishek Tiwari