Weble / ZohoBooksApi

40 stars 42 forks source link

"code":15,"message":"Please ensure that the line_items has less than 100 characters." #62

Closed ibmgeniuz closed 3 years ago

ibmgeniuz commented 3 years ago

Hello @Skullbock , Can you please give me a code example of how you create invoices? My code below results to this error response

exception: "GuzzleHttp\Exception\ClientException"
file: "/Path/to/application/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php"
line: 113
message: "Client error: `POST https://books.zoho.com/api/v3/invoices?organization_id=[organization_id]` resulted in a `400 Bad Request` 
response:↵{"code":15,"message":"Please ensure that the line_items has less than 100 characters."}

Another request deleting most of the things in line items gave the response below but I do not have such

response:↵{"code":15,"message":"Please ensure that the Stripe has less than 100 characters."}

This is a sample of my code

$line_items = ['item_id' => $item_id, 'purchase_rate' => $total, 'tax_id' => $tax_id, 'rate' => total, 
'discount' => $discount, 'description' => $description,  'sku' => $sku ?? ''];

$invoice = [
            "customer_id" => $customer_id,
            "reference_number" => $invoice_number,
            "is_inclusive_tax" => $is_inclusive_tax,
            'line_items' => [
                $line_items
            ],
            'payment_options' => [
                'payment_gateways' => [
                    0 => [
                        'configured' => true,
                        'can_show_billing_address' => false,
                        'additional_field1' => "standard",
                        'is_bank_account_applicable' => false,
                        'gateway_name' => "paypal",
                    ],
                    1 => [
                        'configured' => true,
                        'can_show_billing_address' => false,
                        'is_bank_account_applicable' => false,
                        'gateway_name' => "stripe",
                    ]
                ]
            ],
        ];

return $this->zohoBooks->invoices->create($invoice)->getData(); 
ibmgeniuz commented 3 years ago

Fixed. I removed description and it worked. However, I think reducing the length will work any way. I will close this now.