I created the sample REST api class (found here) in my developer org, and I'm trying to hit it from javascript on a visualforce page in the same org, but I'm getting the following error:
"NetworkError: 405 Method Not Allowed - https://na9.salesforce.com/services/apexrest/Account/001E000000B9GjD"
From the guide in the link mentioned above, a 405 means "The request method does not have a corresponding Apex method." Any ideas? Here's the related code:
Apex class:
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
@HttpGet
global static Account doGet(RestRequest req, RestResponse res) {
...
}
}
Visualforce page (in javascript):
var session = '{!$Api.Session_ID}';
var Url = "https://na9.salesforce.com/services/apexrest/Account/001E000000B9GjD";
xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = ProcessRequest;
xmlHttp.open( "GET", Url, true );
xmlHttp.setRequestHeader('Set-Cookie', session);
xmlHttp.send( null );
urlMappingattribute? - Brian Driscoll