Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to retrieve any items #339

Open
Tadaz opened this issue Feb 16, 2024 · 0 comments
Open

Impossible to retrieve any items #339

Tadaz opened this issue Feb 16, 2024 · 0 comments
Labels

Comments

@Tadaz
Copy link

Tadaz commented Feb 16, 2024

I am using the latest version of 3.1.1 and SharePoint online.

The only working snippet I got using this library is below - I can retrieve the root list of lists, any other command returns an empty list.

$credentials = new \Office365\Runtime\Auth\UserCredentials("USERNAME", "PASSWORD");
$ctx = (new \Office365\SharePoint\ClientContext("URL"))->withCredentials($credentials);

foreach ($ctx->getWeb()->getLists()->get()->executeQuery() as $list) {
    dump($list->getId() . ' ' . $list->getTitle());
}

I tweaked the code above to return all items from the Documents list but it always returns an empty list.

$credentials = new \Office365\Runtime\Auth\UserCredentials("USERNAME", "PASSWORD");
$ctx = (new \Office365\SharePoint\ClientContext("URL"))->withCredentials($credentials);

foreach ($ctx->getWeb()->getLists()->get()->executeQuery() as $list) {
    if($list->getTitle() === 'Documents') {
        $listItems = $list->getItems()->get()->executeQuery();
    
        //RETURNS EMPTY LIST OF ITEMS
        foreach ($listItems as $item){
            dump($item->getTitle());
        }
    }
}

I tried other different ways as well, e.g.

$credentials = new \Office365\Runtime\Auth\UserCredentials("USERNAME", "PASSWORD");
$ctx = (new \Office365\SharePoint\ClientContext("URL"))->withCredentials($credentials);

$list = $ctx->getWeb()->getList("Shared Documents")->executeQuery();
$listItems = $list->getItems()->get()->executeQuery();

//SAME ISSUE, THE LIST IS EMPTY
foreach ($listItems as $item){
    dump($item->getTitle());
}

I have read and edit permissions for the whole project.

Any suggestions?

@vgrem vgrem added the question label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants