• sachin kumar 175
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
I have created a simple REST service which fetches the Account Id,Name and the associated Contacts. Whenever I try to reach this web service from Workbench using this URI : services/apexrest/checkCMT/Accounts/0019000001NQXpJ/contacts , it gives the error 'Service Not Found'

where checkCMT is the namespace I am using in my org.

Here is the code that I have written.

@RestResource(urlMapping='/Accounts/<Account_ID>/contacts')
global with sharing class AccountManager {

    @HttpGet
    global static Account getAccount() {
        RestRequest request = RestContext.request;
        // grab the AccountId from the mid of the URL
        String accountId = request.requestURI.substringBetween('Accounts/', '/contacts');
        Account result =  [SELECT Id,Name, (select Id,Name from Contacts)
                        FROM Account
                        WHERE Id = :accountId];
        return result;
        
    }


}