How to create an invoice in invoices.zoho?

How to create an invoice in invoices.zoho?

    I have some code to create an invoice in invoices.zoho:
    1. $invoice = array(
    2.     'customer_id' => 918439000000063105,
    3.     'contact_persons' => array('918439000000063085'),
    4.     'invoice_number' => 'TEST-00001',
    5.     'reference_number' => '',
    6.     'template_id' => 918439000000017001,
    7.     'date' => '2017-09-28',
    8.     'payment_terms' => 0,
    9.     'payment_terms_label' => 'Pagadero a la recepcion',
    10.     'due_date' => '2015-10-28',
    11.     'discount' => 0,
    12.     'is_discount_before_tax' => true,
    13.     'discount_type' => '',
    14.     'is_inclusive_tax' => false,
    15.     'exchange_rate' => 0.103627,
    16.     'recurring_invoice_id' => '',
    17.     'invoiced_estimate_id' => '',
    18.     'salesperson_name' => '',
    19.     'custom_fields' => array(),
    20.     'line_items' => array(
    21.         array(
    22.             'item_id' => 918439000000063265,
    23.             'project_id'  => '',
    24.             'expense_id'  => '',
    25.             'salesorder_item_id'  => '',
    26.             'name'  => 'Khách sạn Hạ Long-Luxury',
    27.             'description' => '',
    28.             'product_type' => 'goods',
    29.             'item_order' => 1,
    30.             'rate'  => 120,
    31.             'unit'  => '',
    32.             'quantity'  => 2.0,
    33.             'discount'  => 0,
    34.             'tax_id'  => ''
    35.         )
    36.     ),
    37.     'payment_options' => array(),
    38.     'allow_partial_payments' => false,
    39.     'custom_body' => '',
    40.     'custom_subject' => '',
    41.     'notes' => 'T.C. $ 9,65',
    42.     'terms' => '',
    43.     'shipping_charge' => 0.0,
    44.     'adjustment' => 0.0,
    45.     'adjustment_description' => 'Ajuste'
    46. );

    47. $url = 'https://invoice.zoho.com/api/v3/invoices/';
    48. $data = array(
    49.   'authtoken'     => '{AUTHORTOCKEN}',
    50.   'JSONString'    => $invoice,
    51.   "organization_id"   => '{organization_id}',
    52.   "send"                  => false
    53. );
    54. $ch = curl_init($url);
    55. curl_setopt_array($ch, array(
    56.   CURLOPT_POST => 1,
    57.   CURLOPT_SSL_VERIFYPEER => false,
    58.   CURLOPT_SSL_VERIFYHOST => false,
    59.   CURLOPT_POSTFIELDS => http_build_query($data),
    60.   CURLOPT_RETURNTRANSFER => true,
    61.   CURLOPT_POST => true,
    62.   CURLOPT_HTTPHEADER => array("Content-Type:application/x-www-form-urlencoded")
    63. ));

    64. $response = curl_exec($ch);
    65. $response = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    66. curl_close($ch);

    67. var_dump($response);
    Why I alway get message error 400 or ' {"code":4,"message":"Invalid value passed for JSONString"} '?

        Zoho Developer Community









                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                      Zoho WorkDrive Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Tips

                                                                            Tips

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now