I have created the following class
@RestResource(urlMapping='/Expense/*')
global class ExpenseWS
{
@HttpPost
global static void createExpense(String ExpenseName,String Type,Integer Amount)
{
Expenses__c e = new Expenses__c();
e.Expense_Name__c = ExpenseName;
e.Type__c = Type;
e.Amount__c = Amount;
insert e;
}
}
And I am able to successfully insert a expense using workbench REST explorer as shown below.
I would like to get the URI (endpoint) for this particular REST class so that I can invoke this REST resource from another org.
As per the guides I need to use the following notation.
https://ap2.salesforce.com/services/apexrest/Expense
I am not sure whether this is right because there is no unique org identifier in the above URI.
There could be thousands of instances under ap2.salesforce.com
I hope I am making sense.
Q : How to get the endpoint/URI for the above REST resource ?
UPDATE
Thanks .
The scenario which I am testing consist of two SF orgs..one sending expense data and another inserting expense data.
As such I have added the second org which absorbs the data sent (i.e where the post rest resource exists) in the first org's "Security Controls"->"Remote Site Settings".
I observed the following .
Can someone explain why the /services/apexrest/expense part of the URL is not accepted as endpoint by Salesforce ?
Best Answer
You have to authenticate before you can call the rest resource. You authentication is what allows you to access the endpoint
https://developer.salesforce.com/blogs/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html