You need to sign in to do that
Don't have an account?
azu.shaik1.3965080575576013E12
how to write test class to delete a record in apex rest api in salesforce
@HttpDelete
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
delete account;
}
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
delete account;
}
Rest context can be created in test class. Look as following link: http://blog.jeffdouglas.com/2012/03/21/writing-unit-tests-for-v24-apex-rest-services/