+ Start a Discussion

Not able to query the inserted case.

I have created one REST API in Apex which takes paramters and create a case and in return I have to send Case Number of the created case. The problem is when I am trying to query the case object with the help of the case id generated in insert query, I am getting this error : List has no rows for assignment to SObject

global static String doGet() { 
   Case c = new Case (
        Subject = 'Test',
        Status = 'New'      
   Insert c;
   System.debug('Case ID: ' + c.id);
   Case newCase = [Select id, CaseNumber from Case WHERE id =:c.Id];
    return (String.valueOf(newCase));
James LoghryJames Loghry
What does your OWD (Sharing settings) look like for cases?  Are they set to private?  I'm curious if the Case is routed to some other person, and thus hidden from the person calling the webservice.  Have you tried adding without sharing to the class just to see what happens?