shaneharris Posted February 3, 2017 Report Share Posted February 3, 2017 Hi There, I'm trying to generate an invoice using the API. I have included the contents of my 'vars' parameter that is sent to the API. The response i'm getting is just {"message":"The format requested is not supported by the server.","response":null} Is it something simple i'm missing here? Setting an option when I shouldn't be? The docs at http://source-docs.blesta.com/class-Invoices.html do not specify which options are optional on the invoice ( they do for lines of the invoice ) so I wasn't sure which ones were required. Does the invoice term need to match the service term some how? Update: I notice two of my lines below have a zero amount. I have tried without these and its the same result. Thanks in advance for any help! <?php $vars = array ( 'vars' => array ( 'client_id' => 119, 'currency' => 'GBP', 'status' => 'active', 'lines' => array ( 0 => array ( 'service_id' => 108, 'description' => 'Minute Bundles', 'amount' => 5, 'tax' => true, 'qty' => 1, ), 1 => array ( 'service_id' => 108, 'description' => 'Included Top Up', 'amount' => 0, 'tax' => true, 'qty' => 1, ), 2 => array ( 'service_id' => 108, 'description' => 'Intergalactic Minutes Bundles', 'amount' => 0, 'tax' => true, 'qty' => 1, ), 3 => array ( 'service_id' => 108, 'description' => 'Handware Option', 'amount' => 65, 'tax' => true, 'qty' => 1, ), 4 => array ( 'service_id' => 108, 'description' => 'Plumbus Deluxe McSneeze', 'amount' => 100, 'tax' => true, 'qty' => 1, ), ), 'date_billed' => '2017-02-03 11:36:11', 'due_date' => '2017-02-10 11:36:11', 'term' => 1, 'period' => 'month', 'duration' => 'indefinitely', ), ); ?> Quote Link to comment Share on other sites More sharing options...
shaneharris Posted February 3, 2017 Author Report Share Posted February 3, 2017 OK I have since solved this issue. the above php array is purely for display purposes but i'm actually consuming the blesta API using javascript. The problem lay in how I was converting the vars to a query string which I have now solved using the 'qs' node module and some tweaks to ensure PHP could parse the complex array OK from the query string. I now have a new issue as is usually the case lol. the 'Invoices->add' request is show a more friendly error - { "message":"The request cannot be fulfilled due to bad syntax.", "errors":{ "date_due":{ "format":"The due date is in an invalid date format." } }, "response":null } my date format is this: { 'date_billed' : '2017-02-03 11:36:11', 'due_date' : '2017-02-10 11:36:11' } Is there something wrong with those dates in combination?? Quote Link to comment Share on other sites More sharing options...
shaneharris Posted February 3, 2017 Author Report Share Posted February 3, 2017 Ok I now see i have 'due_date' rather than 'date_due'. I had previously been using the 'Invoice->createFromService' and its parameter is 'due_date' rather than 'date_due'; All working ok now! Paul and Michael 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.