You need to sign in to do that
Don't have an account?
duplicate value found: duplicates value on record with id:
I am getting this error on line 0 in my apex code. This is for spring '19 PD1 maintenance
@RestResource(urlMapping='/secureApexRest')
global with sharing class SecureApexRest {
@HttpGet
global static Contact doGet(){
Id recordId = RestContext.request.params.get('id');
Contact result;
if (recordId == null){
throw new FunctionalException('Id parameter is required');
}
List<Contact> results;
try{
results = [SELECT id, Name, Secret_Key__c FROM Contact WHERE id=:recordId WITH SECURITY_ENFORCED];
}catch(QueryException e){}
if (!results.isEmpty()) {
result = results[0];
}
return result;
}
public class FunctionalException extends Exception{}
public class SecurityException extends Exception{}
}
All Answers