Fatal error: Declaration of Microsoft\Graph\Beta\Generated\Models\ODataErrors\ODataError::getAdditionalData(): ?array must be compatible with

huangapple go评论70阅读模式
英文:

Fatal error: Declaration of Microsoft\Graph\Beta\Generated\Models\ODataErrors\ODataError::getAdditionalData(): ?array must be compatible with

问题

I tried to get data using Microsoft Graph beta API, but it returns the same error results:

// Code 1
$tokenRequestContext = new ClientCredentialContext(
    '[tenantId]',
    '[clientId]',
    '[clientSecret]'
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);

try {
    $response = $betaGraphServiceClient->usersById('[userPrincipalName]')->get();
    $user = $response->wait();
    echo "Hello, I am {$user->getGivenName()}";
} catch (ApiException $ex) {
    echo $ex->getMessage();
}
// Code 2
$tokenRequestContext = new ClientCredentialContext(
    '[tenantId]',
    '[clientId]',
    '[clientSecret]'
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);
$requestConfiguration = new ShiftsRequestBuilderGetRequestConfiguration();
$queryParameters = new ShiftsRequestBuilderGetQueryParameters();
$queryParameters->filter = "startDateTime ge 2023-01-05T06:00:00.000Z and sharedShift/endDateTime le 2023-01-06T06:00:00.000Z";
$requestConfiguration->queryParameters = $queryParameters;
$requestResult = $betaGraphServiceClient->teamsById('teamId')->schedule()->shifts()->get($requestConfiguration);

Please note that you may need to replace [tenantId], [clientId], [clientSecret], [userPrincipalName], and 'teamId' with the actual values you intend to use in your code.

英文:

I tried to get data using Microsoft Graph beta api
"require": {
"microsoft/microsoft-graph-beta": "^2.0.0-RC13",
"microsoft/microsoft-graph-core": "@RC"
}
//code 1
''''

$tokenRequestContext = new ClientCredentialContext(
    ',//tenantId
    '',//clientId
    ''//clientSecret
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);

try {
    $response = $betaGraphServiceClient->usersById('[userPrincipalName]')->get();
    $user = $response->wait();
    echo "Hello, I am {$user->getGivenName()}";

} catch (ApiException $ex) {
    echo $ex->getMessage();
}

''''
//code 2

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
use Microsoft\Graph\Beta\GraphRequestAdapter;
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Kiota\Abstractions\ApiException;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
use Microsoft\Kiota\Authentication\PhpLeagueAuthenticationProvider;
use Microsoft\Graph\Beta\Generated\Teams\Item\Schedule\Shifts\ShiftsRequestBuilderGetRequestConfiguration;
use Microsoft\Graph\Beta\Generated\Teams\Item\Schedule\Shifts\ShiftsRequestBuilderGetQueryParameters;
$tokenRequestContext = new ClientCredentialContext(
    '',//tenantId
    '',//clientId
    ''//clientSecret
);
$scopes = ['https://graph.microsoft.com/.default'];
$authProvider = new PhpLeagueAuthenticationProvider($tokenRequestContext, $scopes);
$requestAdapter = new GraphRequestAdapter($authProvider);
$betaGraphServiceClient = new GraphServiceClient($requestAdapter);
$requestConfiguration = new ShiftsRequestBuilderGetRequestConfiguration();
$queryParameters = new ShiftsRequestBuilderGetQueryParameters();
$queryParameters->filter = "startDateTime ge 2023-01-05T06:00:00.000Z and sharedShift/endDateTime le 2023-01-06T06:00:00.000Z";    
$requestConfiguration->queryParameters = $queryParameters;
$requestResult = $betaGraphServiceClient->teamsById('teamId')->schedule()->shifts()->get($requestConfiguration);

''''
But returns the same error results
Fatal error: Declaration of Microsoft\Graph\Beta\Generated\Models\ODataErrors\ODataError::getAdditionalData(): ?array must be compatible with Microsoft\Kiota\Abstractions\Serialization\AdditionalDataHolder::getAdditionalData(): array in D:...\vendor\microsoft\microsoft-graph-beta\src\Generated\Models\ODataErrors\ODataError.php on line 43

答案1

得分: 1

这是Beta SDK中的一个错误。

这个错误在2.0.0-RC14版本中已解决。

英文:

This was a bug in the Beta SDK.

This bug was resolved in the 2.0.0-RC14 release.

huangapple
  • 本文由 发表于 2023年1月6日 12:00:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75026802.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定