I'm trying to learn REST and for this I tried to create a rest service class with the aim of retrieving accounts. Now whenever I'm executing this in workbench this is showing response code 404. Can someone help me in finding out what wrong I'm doing? Here's the code I did-->


global with sharing class AccountRestService {

global static Account doGet() {

    RestRequest req = RestContext.request;
    RestResponse res = RestContext.response;

    String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
    Account results = [SELECT Name,Phone,Id FROM Account where External_Id__c =:accountId];
    return results;

In workbench i chose GET method and gave this /services/apexrest/v34.0/account/1200. I have created a custom field External_Id__c as Text type .

1 Answer 1


When you define your own service class:

The URL mapping is relative to https://instance.salesforce.com/services/apexrest/.

So in your case try:


You can introduce your own versioning in the @RestResource definition if you want to.

  • Got it :) Gave this URI /services/apexrest/account/1200
    – user13277
    Aug 13, 2015 at 7:56

You must log in to answer this question.