microsoftgraph / msgraph-sdk-php

Microsoft Graph Library for PHP.
Other
578 stars 144 forks source link

Invalid '$skip' queryparameter for some request builders #1467

Open inserve-paul opened 8 months ago

inserve-paul commented 8 months ago

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:

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 commented 8 months ago

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();