I have written a custom REST service in Salesforce as below:
@RestResource(urlmapping='/MyRestWS/*')
global class CustomRestWS
{
@HttpGet
global static String getName()
{
return UserInfo.getUserName();
}
@HttpPost
global static String sayHi(String test)
{
return 'Hi '+test;
}
}
Please clarify my doubts below:
- 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?
- 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?
- Which authentication is most commonly used?
- What is Basic Authentication, how to use Basic Authentication to invoke REST API?
Thanks in advance.