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
Antonio Úbeda MonteroAntonio Úbeda Montero 

Error about refering a Contact from Account returned in method


I have a problem using the returned value marked in yellow. Can anyone tell me what's wrong? I'm a bit stucked! Thank you,
global with sharing class AccountManager {
    global static Account getAccount() {
        RestRequest request = RestContext.request;
        // grab the caseId from the end of the URL
        String AccountId = request.requestURI.substring(
        Account result = [SELECT ID,Name,(SELECT ID,Name
                                          FROM Contacts)
                          FROM Account
                          WHERE ID=:AccountId
                          LIMIT 1];
        return result;