Zoho error "`400 Bad Request`": mandatory param missing

Viewed 356

Trying to make search record api call but giving error "mandatory param missing" even specifying phone in form_params.

public function execute(){
        $client = new Client();
        $phone = 9XXXXXXXX9;
        $token['Authorization']='Zoho-oauthtoken '.'1000.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
        $deals = $client->request('GET', 'https://www.zohoapis.in/crm/v2/Leads/search', [
            'form_params' => [
                'phone' => $phone
            ],
            'headers' => [
                'Authorization'=>$token
            ]
           
        ]); 
        dd($deals);
}

What is the issue Here? Thanks in advance.

Here is the error message

1 Answers

You're trying to make a GET request but specifying your parameters as if it were a POST.

Use query on your $params:

$deals = $client->request('GET', 'https://www.zohoapis.in/crm/v2/leads/search', [
    'query' => [ // <-- query, not form_params
        'phone' => $phone
    ],
    'headers' => [
        'Authorization' => $token
    ]
]); 

You might want to consider using the official ZOHO CRM API to make your life a little simpler.

Related