Skip to content

Call to a member function getEntityType() on null in vendor\coolrunner\business-central-sdk\src\EntityCollection.php:59 #17

@thomasa00

Description

@thomasa00

Hi,
I'm getting the error Call to a member function getEntityType() on null when I try to do any query.
It seems the problem starts in `EntityCollection.ph , line 77:

$this->type        = $this->query->getEntitySet($response['@odata.context']);

$response['@odata.context'] has a valid content:
https://api.businesscentral.dynamics.com/v2.0/myTenant/sandbox/ODataV4/$metadata#Company

$response looks good as well (array of value is there; 1 element in it, with Name, Display_Name, Id, ...

But $this->query->getEntitySet returns null

Complete usage of SDK:

$sdk = \BusinessCentral\SDK::instance($myTenant, [
    // OAuth2 [Required]
    'client_id' => $myClientId,

    // Basic auth token [Required]
    'client_secret'    => $mySecret,

    // Default collection size [Optional]
    // Amount of entities to load initially and per page per collection
    // Can be changed on the fly on any collection instance
    'default_collection_size' => 20,

    // Default environment [Optional - 'production' by default]
    'environment' => 'sandbox',
]);

$company = $sdk->company('company');

At creating the instance some warnings will come - maybe this is the reason?

Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "Namespace" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "Namespace" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "@attributes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 40

Warning: Undefined array key "NAV.ComplexTypes" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55

Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 55

Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59

Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 59

Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63

Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 63

Warning: Undefined array key "NAV" in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67

Warning: Trying to access array offset on value of type null in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67

Warning: foreach() argument must be of type array|object, null given in \vendor\coolrunner\business-central-sdk\src\Schema.php on line 67

PHP Version: 8.1.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions