I am new to HTTP and Salesforce's APIs

What is the difference between the salesforce rest resource they talk about in this trailhead module - https://trailhead.salesforce.com/content/learn/modules/api_basics/api_basics_rest and an HTTP request message? There's also the HttpRequest.... I am not sure how they all fit together

3 Answers 3


This classifies as a very broad question, but some of these pointers should help.

HTTP, REST, HTTP Messages are all inter-related yet different.

HTTP is a protocol used to communicate between client and server to fetch resources.

HTTP is a protocol which allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web and a client-server protocol, which means requests are initiated by the recipient, usually the Web browser.

HTTP Message is term used for the data exchanged between client and server. HttpRequest is one such data which is sent to the server by a client while making a request, and that HttpResponse is the other set of data which is sent back to the client from the server.

HTTP messages are how data is exchanged between a server and a client. There are two types of messages: requests sent by the client to trigger an action on the server, and responses, the answer from the server.

A Salesforce REST Resource is a resource exposed as an API (imagine an Apex class annotated with @RestResource) which is exposed to return certain data based on certain request based on the HTTP protocol and utilizing the HTTP Messages (HttpRequest/HttpResponse) as the component for data exchange. You can find more on REST here.

  • this is fantastic! So in this trailhead module - when they say rest resource they do not mean @restresource, they mean it's a http request into Salesforce? trailhead.salesforce.com/content/learn/modules/api_basics/… Jan 11, 2019 at 21:21
  • 1
    That's correct. REST resource here refers to the literal meaning of the same. The annotation @RestResource will be only required, if you want to code and expose a REST API. Consider how you can call Sobject describe methods, which are already available as a REST (API) Resource provided by Salesforce.
    – Jayant Das
    Jan 11, 2019 at 21:25

The REST API is a set of standard function calls you can use assuming you have API access. For example, you can use /services/data/v44.0/sobjects/Account to create a new account.

The RestResource annotation allows you to build a custom function call you can use for more complicated logic, such as calling /services/apexrest/GetInvoice to get an invoice for an opportunity, using whatever payload (XML, JSON, etc) that you'd like to use.

The HttpRequest class allows Apex classes (Salesforce) to call third-party services. Note that the first two are inbound calls to Salesforce, while the latter is an outbound call from Salesforce to another server.


A @RestResource annotated class is used to receive inbound requests.

An HttpRequest is used to make outbound requests.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .