You need to sign in to do that
Don't have an account?
Stephen Judd - Dev
Apex REST service - List Index out of bounds
In the Trailhead Apex Web Services Unit, my class has 100% test coverage and using the Workbench: REST Explorer, responds correctly to existing accounts with or without associated contacts. If an invalid Id is passed in, I return an empty account.
However, when I Check the challenge, I get "System.ListException: List index out of bounds: 0" problem in response. I'm not sure what's wrong - any pointers?
However, when I Check the challenge, I get "System.ListException: List index out of bounds: 0" problem in response. I'm not sure what's wrong - any pointers?
I executed your code in my org. I think the issue is with the below line of code
You can change the above line to the below :
I think that would work. Please let me know if you find any further issues
Thanks,
Abhiram Sheshadri
All Answers
What's the URL of this unit so I can take a look at the challenges. Can you also post your code?
Thanks
Jeff Douglas
Trailhead Developer Advocate
My code:
Thanks for taking a look. I originally tried getting the account directly, but it would return an arror if there were no associated contacts, so I used this way.
I executed your code in my org. I think the issue is with the below line of code
You can change the above line to the below :
I think that would work. Please let me know if you find any further issues
Thanks,
Abhiram Sheshadri