+ Start a Discussion
Warjie Malibago 8Warjie Malibago 8 

(REST) Could not find a match for URL

Hi All,

I've been stuck with this error for 2 days already.

I've been trying to test a fairly simple REST code in my workbench. But for some weird reason(s), it always show this error (attached)

Here's my code:
@RestResource(urlMapping='/v1/accounts/*')
global with sharing class SampleREST{
  
    @HttpGet
    global static AccountWrapper doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        
        AccountWrapper response = new AccountWrapper();
        
        response.acctList = [SELECT Id, Name FROM Account];
        response.status = 'Success';
        
        return response;
    }
    
    global class AccountWrapper{
        public List<Account> acctList;
        public String status;
        public String message;
        
        public AccountWrapper(){
            acctList = new List<Account>();
        }
    }
}

Of all the articles I've checked, they all point me into 1 direction and it hasn't worked either.

So I was thinking that it might be something that I setup or forget to setup before I had my class created?

Appreciate your help on this.User-added image
 
Best Answer chosen by Warjie Malibago 8
Pankaj_GanwaniPankaj_Ganwani
Hi,

Is there any namespace defined in your org? If yes, then you will have to access your rest resource using:----- /services/apexrest/namespace/v1/accounts

All Answers

Pankaj_GanwaniPankaj_Ganwani
Hi,

Is there any namespace defined in your org? If yes, then you will have to access your rest resource using:----- /services/apexrest/namespace/v1/accounts
This was selected as the best answer
Warjie Malibago 8Warjie Malibago 8
You're so great man! It worked :D Case solved.

Weirdly enough, I have done that yesterday but it didn't work. But now it's working!

Thanks man!
Christopher D. EmersonChristopher D. Emerson
Anyone know if this "org namespace" value needs to be inserted into a CONSTANT (or other) location in the Force.com-Toolkit-for-NET (https://github.com/developerforce/Force.com-Toolkit-for-NET)? Or will that framework figure that value out by itself via the API calls it does?
Christopher D. EmersonChristopher D. Emerson
Just to answer my own question ... I'm pretty sure you specify this value as part of your ExecuteRestApiAsync() call.  For example:
var returnValue = await _client.ExecuteRestApiAsync<string>("MyCustomNameSpace/MyURLMapping", content);
And people who do not have a custom namespace for their org/package would look like this:
var returnValue = await _client.ExecuteRestApiAsync<string>("MyURLMapping", content);