diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 5c6acfb9a84..41ff488136d 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -118,7 +118,7 @@ class DolibarrApiAccess implements iAuthenticate $stored_key = $obj->api_key; $userentity = $obj->entity; - if (! defined("DOLENTITY") && $conf->entity != $obj->entity) // If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user + if (! defined("DOLENTITY") && $conf->entity != ($obj->entity?$obj->entity:1)) // If API was not forced with HTTP_DOLENTITY, and user is on another entity, so we reset entity to entity of user { $conf->entity = ($obj->entity?$obj->entity:1); // We must also reload global conf to get params from the entity