Hi am creating apex trigger using MetaData Service class but i am getting this Exception -
Line: 13432, Column: 1 System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_TYPE: This type of object is not available for this organization faultcode=sf:INVALID_TYPE faultactor=
Sample code -
MetadataService.MetadataPort service2 = new MetadataService.MetadataPort();
service2.SessionHeader = new MetadataService.SessionHeader_element();
service2.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.ApexTrigger objTrigger = new MetadataService.ApexTrigger();
objTrigger.type = 'ApexTrigger';
objTrigger.apiVersion = 45.0;
objTrigger.status = 'Active';
objTrigger.fullName = 'TestTrigger';
string str= 'Trigger TestTrigger on Account (After Insert,After update){}';
//apexPage.label = 'TestPage';
objTrigger.content = EncodingUtil.base64Encode(Blob.valueOf(str));
List<MetadataService.SaveResult> results = service2.createMetadata(new MetadataService.Metadata[] { objTrigger });