I think you can use the System.RestRequest
and System.RestResponse
contexts to achieve that. There's some good examples of REST handlers in the help. Some speculative pseudocode:
@RestResource(urlMapping='/Log/*')
global with sharing class RESTLogController {
@HttpPost
global static String doPost()
{
String body = String.valueOf(System.RestContext.request.requestBody.toString();
Log__c log = (Log__c)System.Json.deserialize(body, Log__c.class);
insert log;
return log.Id;
}
}
Or by manipulating the response:
System.RestResponse response = System.RestContext.response;
response.responseBody = log.Id;