Skip to main content
deleted 5 characters in body
Source Link
Matt and Neil
  • 33.1k
  • 7
  • 107
  • 189

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;

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);
    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;

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 = 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;
added 5 characters in body
Source Link
Matt and Neil
  • 33.1k
  • 7
  • 107
  • 189

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. Along the lines of the followingSome speculative pseudocode:

@RestResource(urlMapping='/Log/*')
global with sharing class RESTLogController {
  
  @HttpPost
  global static String doPost()
  {
    System.RestRequestString requestbody = String.valueOf(System.RestContext.request;request.requestBody);
    Log__c log = (Log__c)System.Json.deserialize(requestbody, Log__c.class);
    
    insert log;
    return log.Id;
  }
  
}

Or by manipulating the response:

System.RestResponse response = System.RestContext.response;
response.responseBody = log.Id;

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. Along the lines of the following:

@RestResource(urlMapping='/Log/*')
global with sharing class RESTLogController {
  
  @HttpPost
  global static String doPost()
  {
    System.RestRequest request = System.RestContext.request;
    Log__c log = (Log__c)System.Json.deserialize(request, Log__c.class);
    
    insert log;
    return log.Id;
  }
  
}

Or by manipulating the response:

System.RestResponse response = System.RestContext.response;
response.responseBody = log.Id;

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);
    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;
Source Link
Matt and Neil
  • 33.1k
  • 7
  • 107
  • 189

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. Along the lines of the following:

@RestResource(urlMapping='/Log/*')
global with sharing class RESTLogController {
  
  @HttpPost
  global static String doPost()
  {
    System.RestRequest request = System.RestContext.request;
    Log__c log = (Log__c)System.Json.deserialize(request, Log__c.class);
    
    insert log;
    return log.Id;
  }
  
}

Or by manipulating the response:

System.RestResponse response = System.RestContext.response;
response.responseBody = log.Id;