Is the following code a RESTful service?
@RestResource(urlMapping='/MyAccount')
global class MyAccount {
@HttpPost
global static Account createAccount(String Name){
Account acc = new Account(name= name);
insert acc;
RestResponse res = RestContext.response;
res.statusCode=201;
return acc;
}
}
Please clarify my below doubts.
1. I read somewhere that a restful service should return statuscode 201 if POST operation is successful and a resource is successfully created. So I am not sure if the above service can be called restful if I don't set statuscode to 201.
2. Also that the response should enclose the location of the resource that is created through the call. If I set return type of the method to void, will it still be RESTful?