In apex rest, when the client wanted to create a Case record in salesforce ... if the user already existed it will create case with OwnerId = requested UserId
other wise it will create a case and queue will take care about owneship.

just important code to understand:

```
list<user> userId = [select id, name from user where username = : objectApexRestRequest.userEmail];
if(!userId.isEmpty()){
 case objLead = getCaseCreation(objectApexRestRequest, userId.id[0]);
 // and return some parameters
}

private static case getCaseCreation(wrapper obj, Id ownerId){ //supporting wrapper class

        return new case(FirstName = obj.FirstName, LastName =obj.LastName, OwnerId = ownerId,Phone = obj.Phone, Email = obj.Email,); 
}

```

Problem is : `userId.isEmpty() == null` , then it passes "ownerId" parameter as null into getCaseCreation method. So , it will cause an error. 

What is the remedy for it 

1. ownerId not empty it will create case with that ownerId
2. ownerId is equal to empty it has to create the case record but ownership will be assigned to the queue.