RestContext Class

Contains the RestRequest and RestResponse objects.

System

Use the System.RestContext class to access the RestRequest and RestResponse objects in your Apex REST methods.

The following example shows how to use RestContext to access the RestRequest and RestResponse objects in an Apex REST method.

The following are properties for RestContext.

  • request

    Returns the RestRequest for your Apex REST method.

  • response

    Returns the RestResponse for your Apex REST method.

Returns the RestRequest for your Apex REST method.

public RestRequest request {get; set;}

Type: System.RestRequest

Returns the RestResponse for your Apex REST method.

public RestResponse response {get; set;}

Type: System.RestResponse