I have written a custom REST service in Salesforce as below:

global class CustomRestWS
    global static String getName()
        return UserInfo.getUserName();
    global static String sayHi(String test)
        return 'Hi '+test;

Please clarify my doubts below:

  1. How to invoke it from outside, say from Postman or Java? From Salesforce docs, it is mentioned that "You can set up authorization using OAuth 2.0 or by passing a Session ID." How to authorize using Session ID?
  2. Is it mandatory to create a connected App in Salesforce if we want to invoke a Salesforce REST API? We cannot consume any salesforce REST API(even standard REST API) without creating a connected app?
  3. Which authentication is most commonly used?
  4. What is Basic Authentication, how to use Basic Authentication to invoke REST API?

Thanks in advance.

1 Answer 1


You can access it as


If you want to use Oauth flow then I think you need the connected app. You can also expose your web service publically using Site guest user profile then you don't need any authentication or connected app.


this is how your request will look

A Basic curl example

for instance:

curl -d "grant_type=password&client_id={client_id}&client_secret={client_secret}&[email protected]&password={Password}{SecurityToken}" "https://login.salesforce.com/services/oauth2/token"

... will return


More detail can be found here or here

The Most commonly used Authentication is OAuth 2.0 and its globally accepted on all major sites.

In Basic authentication we pass Username and password in request and I don't think SF support this authentication in accesing REST services.

There is a very good step by step example provided here

You must log in to answer this question.

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