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
SK_SFSK_SF 

Apex rest service to Search for a user using HttpPost method

Request sample body :
 "email": "email@email.email",
    "firstName": "test",
    "lastName": "test",
 

Can someone please help? to implement this api.
Shivdeep KumarShivdeep Kumar
Hi
Please see the sample code to fetch the user--
 
@RestResource(urlMapping='/api/searchUser/*')
global with sharing class searchUserRESTAPI{

@HttpPost
    global static String doPost(String firstName,String lastName,String email ) {
        User user = [Select Id from User Where FirstName=: firstName AND LastName=:lastname AND Email=:email LIMIT 1];

return user.Id;
}
}

Please let me know if this help!

Thanks,