英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论