Closed MatthieuTexier closed 4 years ago
IF you setup dolibarr (configuration->thirdparties) with a required customer code, it mean you should give it to the API when you set to customer status
You can also set the value to 'auto' when calling API.
IF you setup dolibarr (configuration->thirdparties) with a required customer code, it mean you should give it to the API when you set to customer status
The setup is Monkey mode, codes are generated by Dolibarr, I don't want to create one by myself.
You can also set the value o 'auto' when calling API.
Thank you Laurent, it works for me too when setting "client" to "1" and "code_client" to "auto"
worked on 7.0.3 but not on 8.0.3
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'DOLAPIKEY: XXXXXXXXXXXXXX' -d '{ "client": "1", "client_code": "auto", "name": "customer" }' 'http://mon_serveur/dolibarr/api/index.php/thirdparties'
fails with error { "error": { "0": null, "1": "ErrorCustomerCodeRequired", "code": 500, "message": "Internal Server Error: Error creating thirdparty" } }
This issue is stale because it has been open 1 year with no activity. If this is a bug, please comment to confirm it is still present on latest stable version. if this is a feature request, please comment to notify the request is still relevant and not yet covered by latest stable version. Without comment, this issue will be closed automatically by stale bot in 15 days.
In the source code, you need to set '-1' for automatic assignment of client code_client
. The same for code_fournisseur
The curl request will be like this :
curl -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'DOLAPIKEY: XXXXXXXXXXXXXX' \
-d '{
"client": "1",
"client_code": "-1",
"name": "customer"
}' 'http://mon_serveur/dolibarr/api/index.php/thirdparties'
I'm on version 13.0.5
For me the key is code_client and not client_code
When creating a thirdparty setting customer to "1", server returns an error ErrorCustomerCodeRequired but customer codes are created by the server.
sample command to reproduce: curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'DOLAPIKEY: XXXXXXXXXXX' -d '{ "client": "1", "name": "TEST" }' 'http://XXXXXXX/dolibarr/api/index.php/thirdparties'