function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stéphane CStéphane C 

RestRessource not found


I'm trying the RestRessource functionality in Apex and I'm facing a "service not found" every time. Here's how I do it :

First, I create a simple Apex class that return "Hello World" on a GET request.
global with sharing class ApexRestTest {

    global static String getMethod()
        return 'Hello World';
Then after saving I go to the workbench connect to the right Organization as Administrator and in the "utilities > REST explorer" I perform this request :
  • GET
  • /services/apexrest/test/123
The response is the following (with the 404 code):
[ {
  "errorCode" : "NOT_FOUND",
  "message" : "Could not find a match for URL"
} ]
On the trailhead it just looks as easy as I did so I don't understand what's wrong.

If any of you have a solution !
Best Answer chosen by Stéphane C
Pankaj ShakyaPankaj Shakya
Hi Stéphane C

If you have a namespace defined in your salesforce org, you need to define it with request URI as /services/apexrest/<namespace>/test/

User-added image

Hope you find this useful.

Pankaj Shakya