Create Invoice php

Create Invoice php

Hello,

I'm trying to create an invoice on Zoho Books using API, using the sample you provide on the documentation.

But I'm getting the following error:

Return:
{"code":4,"message":"Invalid value passed for JSONString"}


The code I'm using is:

<?php
$invoice = array(
    'customer_id' => '198938000001208463',
    'contact_persons' => array("198938000001222003"),
    'invoice_number' => 'TEST-00001',
    'reference_number' => '123456',
    'template_id' => '198938000000124001',
    'date' => '2015-11-23',
    'payment_terms' => 0,
    'payment_terms_label' => 'Pagadero a la recepcion',
    'due_date' => '2015-11-28',
    'discount' => '0%',
    'is_discount_before_tax' => true,
    'discount_type' => 'item_level',
    'is_inclusive_tax' => false,
    'exchange_rate' => 0.103627,
    'recurring_invoice_id' => '',
    'invoiced_estimate_id' => '',
    'salesperson_name' => '',
    'custom_fields' => array(),
    'line_items' => array(
        array(
            'item_id'=>'198938000000021015',
            'project_id'=>'',
            'expense_id'=>'',
            'salesorder_item_id'=>'',
            'name'=>'GATE-IN',
            'description'=>'',
            //'item_order'=>0,
            'rate'=>241.25,
            'unit'=>'CONTAINER',
            'quantity'=>2.0,
            'discount'=>'0%',
            'tax_id'=>'198938000000023286'
        )
    ),
    'payment_options' => array('payment_gateways' => array()),
    'allow_partial_payments' => false,
    'custom_body' => '',
    'custom_subject' => '',
    'notes' => 'T.C. $ 9,65',
    'terms' => '',
    'shipping_charge' => 0.0,
    'adjustment' => 0.0,
    'adjustment_description' => 'Ajuste'
);

$jsonInvoice = json_encode($invoice);


$data = array(
        'authtoken'   => '[Auth Token]',
        'JSONString'   => $jsonInvoice,

        "organization_id"  => '6217732',
        "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, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json") );

$response = curl_exec($ch);
curl_close($ch);

var_dump($response);

Can you please help?

Regards,