+ Start a Discussion

where clause in rest query (php) doens't work

Hi all, I got authentication and a first query ($query1) working, but I don't succeed making a query with a where clause in it ($query2). It results in a Bad Request. Any help is greatly appreciated.
$instance_url = Salesforce_user::get_instance_url($cg_user_id);

        $name = 'Guido';
        $query1 = "SELECT email , name , FirstName FROM LEAD LIMIT 1";
        $query2 = "SELECT email ,name, FirstName WHERE FirstName = '$name' FROM LEAD LIMIT 1";

        $query_encoded = urlencode($query1);
        $url = $instance_url . "/services/data/v45.0/query/?q=".$query_encoded;

        $options['headers']['content-type'] = 'application/json';
        $request = ApiController::$provider->getAuthenticatedRequest(
            ApiController::static_oauth_get_access_token($cg_user_id), $options

Best Answer chosen by CVSoft

Where clause should come after from

try this

$query2 = "SELECT email ,name, FirstName FROM LEAD WHERE FirstName = '$name' LIMIT 1";