Salesforce provides a example of how to define a custom rest endpoint and how to make calls to that endpoint. It is not working for me. Why? I have successfully retrieved an OAuth token that I have successfully used with the REST Api.
Here is the Rest class in apex:
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpDelete
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Account account = [SELECT Id FROM Account ];
delete account;
}
@HttpGet
global static Account doGet() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
Account result = [SELECT Id, Name, Phone, Website FROM Account];
return result;
}
@HttpPost
global static String doPost(String name,
String phone, String website) {
Account account = new Account();
account.Name = name;
account.phone = phone;
account.website = website;
insert account;
return account.Id;
}
}
and here is some python code that I am using to make the get request:
import requests
url = 'https://na15.salesforce.com/services/apexrest/Account/001i000000VdaoqAAB'
headers = {'Authorization': 'Bearer 00Di0000000iQ.....'}
r = requests.get(url, headers=headers)
print r.text
I am getting the following error:
[{"message":"Could not find a match for URL /Account/001i000000VdaoqAAB","errorCode":"NOT_FOUND"}]
Is there some setting that I need to enable?