msgraph-sdk-php icon indicating copy to clipboard operation
msgraph-sdk-php copied to clipboard

Invalid '$skip' queryparameter for some request builders

Open inserve-paul opened this issue 4 months ago • 1 comments

I found this by using several API calls in combination with the 'top' and 'skip' queryParameters. I get the following error response message: "'$skip' is not supported by the service."

Since $skip is not supported, but the skipToken is. The request builders don't seem right for at least these builders:

  • Microsoft\Graph\Generated\Groups\Item\Members\MembersRequestBuilderGetRequestConfiguration
  • Microsoft\Graph\Generated\Groups\GroupsRequestBuilderGetRequestConfiguration

I want to use pagination when calling these endpoints, but it is just not possible with the v2 version of the SDK. For e.g. some example code:


$offset = 5;
$limit = 10;

$requestConfig = new MembersRequestBuilderGetRequestConfiguration(
    queryParameters: MembersRequestBuilderGetRequestConfiguration::createQueryParameters(
        skip: $offset,
        top: $limit,
    )
);

$members = $graphClient
    ->groups()
    ->byGroupId($groupId)
    ->members()
    ->get($requestConfig)
    ->wait();

inserve-paul avatar Feb 20 '24 15:02 inserve-paul

Solved by using the 'withUrl' method; however the 'skip' parameter should still not be part of the RequestBuilders since it's not allowed on the API.


$members = $graphClient
    ->groups()
    ->byGroupId($groupId)
    ->members()
    ->get($requestConfig)
    ->wait();


// And the follow-up call:
$nextDataLink = $members->getOdataNextLink();

$members = $graphClient
    ->groups()
    ->byGroupId($groupId)
    ->members()
    ->withUrl($nextDataLink)
    ->get($requestConfig)
    ->wait();

inserve-paul avatar Feb 21 '24 12:02 inserve-paul