Create order with REST API

Hi, I am trying to create a system where my maintenance software creates an automatic order object for every bike maintenance I make. I am able to create a customer with REST API, it was an easy task, but to create an order is not working. This is the JSON I try to post to “orders”:

{
  "socid":"133",
  "type":"0",
  "lines":[
    {"qty":"1","fk_product":"4102"},
    {"qty":"1","fk_product":"5785"}
  ],
  "note_private":"API-order"
}

But instead of creating on order, all I get is this:

array(2) {
  ["error"]=>
  array(2) {
    ["code"]=>
    int(400)
    ["message"]=>
    string(31) "Bad Request: date field missing"
  }
  ["debug"]=>
  array(2) {
    ["source"]=>
    string(38) "api_orders.class.php:928 at call stage"
    ["stages"]=>
    array(2) {
      ["success"]=>
      array(5) {
        [0]=>
        string(3) "get"
        [1]=>
        string(5) "route"
        [2]=>
        string(9) "negotiate"
        [3]=>
        string(12) "authenticate"
        [4]=>
        string(8) "validate"
      }
      ["failure"]=>
      array(2) {
        [0]=>
        string(4) "call"
        [1]=>
        string(7) "message"
      }
    }
  }
}

I am using 12.0.1. Does anyone have any idea what might be wrong there?

hi,
it tells you that it missed date and in the example of the API it is written :
{ “socid”: 2, “date”: 1595196000, “type”: 0, “lines”: [{ “fk_product”: 4, “qty”: 1 }] }
1595196000 = is an epoch date , q=see https://www.epochconverter.com/ and it tells that this number is GMT : Sunday 19 July 2020 22:00:00
if I put this example in my version 12.0.2, I get success and :slight_smile: Response Body : 5

Response Code 200

and body corresponds to the “(PROV5)” it created ; that you have to valide after.
OK ?

1 Like

That was it! Thank you!

I’m curious. What maintenance software do you use? Is it free software? What does it do that Dolibarr can’t do?
I run a local bikeshop and exclusively use Dolibarr to handle my customers. I have added a lot of extrafields to make it store the information I need to help the customers.

Dolibarr didn’t solve the scheduling and record keeping, and I didn’t find any ready-made maintenance software. So during the years I did my own on PHP. If you like, I can demonstrate it to you sometime.

1 Like

I’m interested :smiley: Can you post some screenshots or a video somewhere?