We are an experienced development group who develops RESTful interfaces. We need to get information the backside of our interface from dolibarr. We are able to retrieve individual tickets with no issues, but are getting a 503 when we attempt to retrieve a list of tickets with all tickets or utilizing sqlfilters:
2026-05-29 08:53:35 ERR 192.168.127.1 55 33 DoliDBMysqli::query Exception in query instead of returning an error: Unknown column 't.status' in 'WHERE'
2026-05-29 08:53:35 ERR 192.168.127.1 55 33 DoliDBMysqli::query SQL Error message: DB_ERROR_NOSUCHFIELD Unknown column 't.status' in 'WHERE' From /var/www/html/ticket/class/api_tickets.class.php:288.
I also tried with t.statut, but that gives the same message.
I got that from the dolibarr.log file in the documents folder, and I have configured Dolibarr in the setup and module setup of ‘debug’ to log level debug.
My next step would be to go and look at the source code in the file it suggests.
And since I don’t see any t.statut or t.status there I’d look in the table definition.
Here I notice that the field sees to be called fk_statut so I’d insert that into the sqlfilter as this (t.fk_statut:<:8). While I am in develop branch, I do get a better answer, hope this method helps.
That is excellent information. We were able to change the sqlfilter and we are getting a blank (empty) result set. Thanks for this information and location of dolibarr.log file so we can start to trace this down. I have a feeling it has to do with user permissions.
I may need to create a new posting for this, but carrying on we made the change in the sqlfilter and we are no longer getting error 503, but getting return 200 indicating this is all good, but not getting any tickets returned. Looking at the query that was generated we see:
SELECT t.rowid FROM llx_ticket AS t
LEFT JOIN llx_societe AS s ON (s.rowid = t.fk_soc)
LEFT JOIN llx_ticket_extrafields AS ef ON (ef.fk_object = t.rowid)
WHERE t.entity IN (1)
AND EXISTS (SELECT sc.fk_soc FROM llx_societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = 1)
AND ((t.fk_statut < 8))
ORDER BY t.rowid ASC LIMIT 100
the WHERE clause condition:
AND EXISTS (SELECT sc.fk_soc FROM llx_societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = 1)
is false as our system has no entries in the lix_societe_commerciaux table. We have found various changes to Home>Setup>Other Setup like setting:
MAIN_TICKET_DISABLE_RESTRICTIONS=1
But this does not appear to remove this from the generated SQL.
We have found parts of list.php in c:\XAMPP\HTDOCS\DOLIBARR\ticket that we could maybe edit but I think list.php is for the GUI, not for the API return. In list.php at line 474:
I think you have to look in this file for the ticket API
if ($search_sale && $search_sale != '-1') {
if ($search_sale == -2) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
} elseif ($search_sale > 0) {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
}
}
So that variable, $search_sale is defined a little above
$socid = DolibarrApiAccess::$user->socid ?: $socid;
$search_sale = null;
// If the internal user must only see his customers, force searching by him
$search_sale = 0;
if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) {
$search_sale = DolibarrApiAccess::$user->id;
}
So my guess is that if you just give your API user the right to read all? thirdparties then your API user should have access @bwarnerserviceadinco
I made the same assumption giving apiuser the right to read all was the way to go, but I do not see this setting anywhere. I see at line #251 of api_tickets.callas.php the start of the code to Search on sale and there is a variable $search_sale that is checked and if it exsits there is an if condition whether $search_sale == -2 or otherwise. This is where $sql is appended with either:
if ($search_sale == -2) {
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc)";
} elseif ($search_sale > 0) {
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = t.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
}
The company we are working for only uses the Ticket Module and does not use Third Parties. I turned this module on and gave apiuser all permissions and now the Ticket search is working! We are going to continue working with this.
Thanks again for all the information! This is excellent.