[SalesForce] URI of Apex REST Class

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.

enter image description here

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 .

enter image description here

enter image description here

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

A little while ago, Paul McGurn blogged how to create a public (SOAP-based) web service via a Force.com Site. As Paul explains, you add your web service class to the Enabled Apex Classes in the Site’s Public Access Settings. You’ll also need to add the appropriate object and field-level permissions for any data you will be exposing; remembering, of course, that this web service will be accessible without any authentication!

As I was setting up a WebHook the other day, I realized that the same principle applies to Apex REST Methods – add the class and any relevant objects/fields to your Site’s Public Access Settings, and you can access the REST methods via the Site URL. Let’s code up a simple example; here’s my Apex class:

https://developer.salesforce.com/blogs/developer-relations/2012/02/quick-tip-public-restful-web-services-on-force-com-sites.html