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
Tiffany Flynn 7Tiffany Flynn 7 

"List has no rows for assignment to SObject" in Einstein Image Classification Trailhead

Cannot figure out why this isn't working for me... are there steps missing in this?!

https://trailhead.salesforce.com/trails/get_smart_einstein/projects/predictive_vision_apex/steps/predictive_vision_apex_vf_page
Best Answer chosen by Tiffany Flynn 7
Arpit Jain7Arpit Jain7
Have you uploaded your einstein key in SFDC file which you must have downloaded when sign up for einstein api using sfdc org as this might be the reason for this error because I was able to complete this trailhead without any issues.

All Answers

jigarshahjigarshah
Tiffany,

This error occurs generally when the result set from the SOQL query that you have written, is being attempted to assign to a single Sobject instance and the executed query returns either more than a single record or no records at all in the result set. 

A Soql query always returns a List<Sobject> based on the Sobject being queried. For e.g. if you are trying to query a list of Accounts you should always assign the result set returned from the query as shown below, instead of assigning it to a single instance of Sobject inspite of the query returning a single row.
List<Account> accountList = [Select Id, Name, CreatedDate from Account Limit 10];

if(accountList.size() > 0){
    //Your dependent business logic goes here
}
One other quick thing to check is to copy the executed query in your code and verify the result set returned by the same using Developer Console.

Refer this help article (https://help.salesforce.com/articleView?id=000159853&type=1) from Salesforce to understand more about this error.

Please do not forget to mark this thread as SOLVED and asnwer as the BEST ANSWER if it helps address your issue.
Arpit Jain7Arpit Jain7
Have you uploaded your einstein key in SFDC file which you must have downloaded when sign up for einstein api using sfdc org as this might be the reason for this error because I was able to complete this trailhead without any issues.
This was selected as the best answer
Ellen HuangEllen Huang
Hi there, I had the similar problem, I can't see any prediction results. And I have uploaded the key, set up the class and page. Could anyone help? Thank you. 
https://trailhead.salesforce.com/trails/get_smart_einstein/projects/predictive_vision_apex/steps/predictive_vision_apex_vf_page
https://c.ap5.visual.force.com/apex/Predict
Rachael HuffmanRachael Huffman
Hi all, I was finally able to figure this out. It has to do with how the file is named. If you go into the File tab (where you uploaded the .pem file), you can access the drop-down next to the .pem file using the down arrow, then edit the name of the file to remove the ".pem" so it shows only as einstein_platform. This should allow it to pass correctly into the code. I hope this helps!
Abhishek DevurkarAbhishek Devurkar
One more thing: Windows has an additional file extension that may not be displayed. Ensure that the file extension is not .txt or any other. For the token to work correctly, you need the ".pem" extension.