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

Hi,

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,
  
System.assertEquals(contactoEsperado.get(0).FirstName,Cuenta.Contacts.FirstName);
System.assertEquals(contactoEsperado.get(0).LastName,Cuenta.Contacts.LastName);
 
@RestResource(urlMapping='/Accounts/*/contacts')
global with sharing class AccountManager {
    @HttpGet
    global static Account getAccount() {
        RestRequest request = RestContext.request;
        // grab the caseId from the end of the URL
        String AccountId = request.requestURI.substring(
          request.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT ID,Name,(SELECT ID,Name
                                          FROM Contacts)
                          FROM Account
                          WHERE ID=:AccountId
                          LIMIT 1];
                       
        return result;
    }
}