Zoho Books API Post Contacts Custom_Fields PHP
Hey guys, I'm trying to POST a new contact with a custom field but it's returning the following error:
- "{"code":1038,"message":"JSON is not well formed"}"
Here is my code:
- $invoice = array(
- 'contact_name' => $result[0]['name'],
- 'email' => $result[0]['email'],
- 'custom_fields' => ["index" => "1", "value" => "123456789"]
- );
- $jsonInvoice = json_encode($invoice);
- var_dump($jsonInvoice);
- $url = 'https://books.zoho.com/api/v3/contacts';
- $data = array(
- 'authtoken' => 'c6964fa118ef2ee81cf09642434478f7',
- 'JSONString' => $jsonInvoice,
- "organization_id" => '636609576',
- "send" => 'false'
- );
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_VERBOSE, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded") );
- $response = curl_exec($ch);
- curl_close($ch);
- var_dump($response);
Anybody know how to post a custom field?