CorsWhitelistEntry cors = new CorsWhitelistEntry();
cors.UrlPattern = 'sdfsdf.com';
insert cors;

Wherever I try the above (or any other DML operation), I get an error message:

DML operation ... not allowed on CorsWhitelistEntry

Any way to get past this? (I'm aware of REST/SOAP, but I'd really like to do this through APEX)


1 Answer 1


No,I dont think you can do it through Apex. Try using Metadata API.

  • Metadata API works, yes. I'm just asking for people's experience on this. Commented Jun 29, 2017 at 15:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .