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
SumitkSumitk 

Invalid identifier ' '. Apex identifiers must start with an ASCII letter

Looks like there is problem with space. I am unable to resolve it. There are 590 error in this code. Please advise.
@RestResource(urlMapping='/Testings') 
global without sharing class chromeExtensionAPI {
    
    @HttpGet
    global static String doGet() {
        System.debug('---GET--');
        wrapperClass wc = new wrapperClass();
        wc.name= UserInfo.getName();
        wc.email =UserInfo.getUserEmail();
        return JSON.serialize(wc);
    }
    @HTTPPost
    global static string getDataFromApp(){
        responseDataWrapper rw = new responseDataWrapper();
        rw.success =false;
        system.debug('----POST-----');        
        system.debug( RestContext.request.params);
        system.debug( RestContext.request.params.get('op_type'));
        system.debug( RestContext.request.params.get('username'));
        system.debug( RestContext.request.params.get('task_id'));
        String op_type = RestContext.request.params.get('op_type');
        String username = RestContext.request.params.get('username');       
        String task_id = RestContext.request.params.get('task_id');
        String newstatus = RestContext.request.params.get('op_status');   
        String sort_field = RestContext.request.params.get('sort_field'); 
        String sort_order = RestContext.request.params.get('sort_order'); 
        String searchkey = RestContext.request.params.get('searchkey') != null ? RestContext.request.params.get('searchkey') : '' ; 
        if(op_type != null && username != null){
            switch on (op_type){
                when 'gettask' {
                    System.debug('gettask');
                    rw.success = true;
                    List<TaskWrapper> lsttask = getusertasks(sort_field,sort_order,searchkey);
                    if(lsttask.size() > 0){                        
                        rw.taskData = lsttask;
                    }else{
                       rw.errormsg = 'No Task Found for User : '+username;
                    }
                }
                when 'updatestatus' {
                    System.debug('updatetask');
                    if(task_id != null && newstatus != null ){
                        String responString = updateusertasks(task_id, newstatus);
                        rw.success = true;
                        rw.errormsg = responString;
                        if(!responString.startsWith('Error:')){
                            rw.updatesuccess = true;
                            List<TaskWrapper> lsttask = getusertasks(sort_field,sort_order,'');
                            if(lsttask.size() > 0){
                                rw.taskData = lsttask;
                            }else{
                               rw.errormsg = 'No Task Found for User : '+username;
                            }
                        }
                    }else{
                       rw.errormsg = 'No Task Detail found for Task ID : '+task_id+' AND Status :'+newstatus ;
                    }                    
                }                                            
                when else {
                    System.debug('none of the above');
                    rw.errormsg = 'User operation is not found.';
                }                        
            }
        }else{
            rw.errormsg = 'Error: Missing require Data op_type:'+op_type+' username: '+username;
        }
        System.debug('>>>>>>rw');
        System.debug(rw);
        rw.picklistValues = getStatuslist();
        return JSON.serialize(rw);
    }

    global static  List<TaskWrapper>  getusertasks (String sortCase,String sort_order ,string searchkey) {
        list<TaskWrapper> lstTaskWrapper = new list<TaskWrapper>();
        String query = 'SELECT Id,Name,Project__c,Project__r.Name,Account__c,Account__r.Name,Start_Date__c,Due_Date__c,Status__c FROM Task__c where OwnerId= \''+UserInfo.getUserID()+'\' AND Due_Date__c != null AND Start_Date__c != null AND Status__c != \'Completed\' And (Project__c = null OR  (Project__r.Public_Project_Template__c = false AND Project__r.Project_Template__c = false and Project__r.Archived__c = false and Project__r.Project_Status__c != \'Canceled\' AND complete__c = false)) ';            
        if(searchkey != ''){
            query +=' AND Name like \'%'+searchkey+'%\'';
        }
        switch on sortCase {
            when 'taskname' {
                query +=' ORDER BY Name ';                              
            }
            when 'projectname'{
                query +=' ORDER BY Project__r.Name ';
            }
            when 'accountname'{
                query +=' ORDER BY Account__r.Name ';
            }
            when 'startdate' {
                query +=' ORDER BY Start_Date__c ';
            }
            when 'duedate'{
                query +=' ORDER BY Due_Date__c ';
            }
            when 'taskstatus'{
                query +=' ORDER BY Status__c ';
            }                                           
            when else {
                query +=' ORDER BY Name '; 
                System.debug('sortCase'+sortCase);
            }
        }
        if(sort_order == 'asc'){
           query += ' ASC NULLS LAST';
        }else{
           query += ' DESC NULLS LAST';
        }        
        query +=' limit 50';     
        system.debug('Query');
        system.debug(query);
        list<Task__c> listTask = Database.query(query);
        if(listTask != null){
            for(Task__c taskTeamp : listTask ){
                TaskWrapper tWrapper = new TaskWrapper();
                tWrapper.taskId = taskTeamp.Id;
                tWrapper.taskName = taskTeamp.Name;
                tWrapper.projectId = taskTeamp.Project__c;
                tWrapper.accountId = taskTeamp.Account__c;
                tWrapper.projectName = taskTeamp.Project__r.Name;
                tWrapper.accountName= taskTeamp.Account__r.Name;
                tWrapper.taskStartDate = String.valueOf(taskTeamp.Start_Date__c.format());
                tWrapper.taskDueDate = String.valueOf(taskTeamp.Due_Date__c.format());
                tWrapper.taskStatus = taskTeamp.Status__c;
                lstTaskWrapper.add(tWrapper);
            }
        }
        return lstTaskWrapper;
    }    
   
    global static  String  updateusertasks (String taskId ,String newstatus){
        String resultString = 'Error';
        String query = 'SELECT Id,Name,Project__r.Name,Start_Date__c,Due_Date__c,Status__c FROM Task__c where id= \''+taskId+'\' AND complete__c = false ';             
        Task__c singleTask = Database.query(query);
        singleTask.Status__c = newstatus;
        try{
            update singleTask;
            resultString = 'Task updated successfully.';
        }
        catch(DmlException e){
            resultString = 'Error: In Updateing Task :'+e.getMessage();
        }       
        return resultString;
    }
    
    
    global static map<String,String> getStatuslist(){
     map<String,String> options = new map<String,String>();
            
       Schema.DescribeFieldResult fieldResult = Task__c.Status__c.getDescribe();
       List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
            
       for( Schema.PicklistEntry f : ple){
          options.put(f.getLabel(), f.getValue());
       }       
       return options;
    }
    
    global class wrapperClass {
        String name;
        String email;
        String username;
    }

    global class responseDataWrapper {
        list<TaskWrapper> taskData;
        map<String,String> picklistValues;
        Boolean success;
        Boolean updatesuccess;
        String errormsg;
    }
    
    global class TaskWrapper {
        String taskId;
        String taskName;
        String projectName;
        String accountName;
        String projectId;
        String accountId;
        String taskStartDate;
        String taskDueDate;
        String taskStatus;
        
    }          
}

User-added image
ShirishaShirisha (Salesforce Developers) 
Hi Sumit,

Greetings!

Can you please try by changing the code on the lines where you get the error and please be informed that it could not be the issue with the "Identifiers" but using them in the incorrect way.

Reference:https://developer.salesforce.com/forums/?id=9060G000000MV8PQAW

Kindly mark it as best answer if it helps so that it can help others in the future.

Warm Regards,
Shirisha Pathuri