+ Start a Discussion
tarun jain 110tarun jain 110 

How to set remote site setting through apex class

Hi, i am facing issue in remote site setting.Please provide solution.

Error: Compile Error: Method does not exist or incorrect signature: [MetadataService.MetadataPort].create(List<MetadataService.Metadata>) 


public static void createRemoteSiteSettings()
{   
    MetadataService.MetadataPort service = createService();
    MetadataService.RemoteSiteSetting remoteSiteSettings = new MetadataService.RemoteSiteSetting();
    remoteSiteSettings.fullName = 'Test12345';
    remoteSiteSettings.url = 'http://www.google.com';
    remoteSiteSettings.description='ewf';
    remoteSiteSettings.isActive=true;
    remoteSiteSettings.disableProtocolSecurity=false;
    MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { remoteSiteSettings });
    MetadataService.AsyncResult[] checkResults = service.checkStatus(new List<string> {string.ValueOf(results[0].Id)});
    system.debug('chk' + checkResults );
}

 public static MetadataService.MetadataPort createService()
{
    MetadataService.MetadataPort service = new MetadataService.MetadataPort();
    service.SessionHeader = new MetadataService.SessionHeader_element();
    service.SessionHeader.sessionId = UserInfo.getSessionId();
    return service;
}
NagendraNagendra (Salesforce Developers) 
Hi Tarun,

Please check below post for the relevant information.

https://github.com/financialforcedev/apex-mdapi/issues/78

Hope this helps.

Best Regards,
Nagendra.P