microsoftgraph / microsoftgraph/msgraph-sdk-java

can't access oneDrive recycle bin

Open
#2,327 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:waiting-for-triage type:bug
Dominant language
Java
Stars
444
Forks
154
Avg merge
18h 28m
Merged PRs (30d)
4

Description

Describe the bug

from an app with Application permissions.

I try to get the recycle bin content of a user with using the call listed here
https://learn.microsoft.com/en-us/graph/api/filestoragecontainer-list-recyclebinitem?view=graph-rest-1.0

that is to say
GET /storage/fileStorage/containers/{containerId}/recycleBin/items

In containerId, I put the driveId of the user.

with the last java sdk, it looks like this
graphClient.storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).recycleBin().items().get();

But I get this error
com.microsoft.graph.models.odataerrors.ODataError: One of the provided arguments is not acceptable.

but using the same driveId, this call do work as intended
graphClient.storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).drive()

I do have the permission FileStorageContainer.Selected enabled for the application

I already tried to ask in another place to see if there is a problem with the way I use the call but didn't have any relevant anwers.
https://learn.microsoft.com/en-us/answers/questions/2180582/getting-the-contents-of-the-recycle-bin-from-msgra

Expected behavior

this call
graphClient.storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).recycleBin().items().get();

should give me a list of drive items

How to reproduce

with app permission, call this and put in fileStorageContainerId a user's drive id.

graphClient.storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).recycleBin().items().get();

If the problem is reproduced, you will get an error

here is a complete code

import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.microsoft.graph.models.RecycleBinItemCollectionResponse;
import com.microsoft.graph.serviceclient.GraphServiceClient;
import jakarta.annotation.PostConstruct;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RpiApigraphTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(RpiApigraphTestApplication.class, args);
    }

    @PostConstruct
    public void myMain() {
        final String clientId = "";
        final String tenantId = "";
        final String clientSecret = "";

        final String[] scopes = new String[]{"https://graph.microsoft.com/.default"};

        final ClientSecretCredential credential = new ClientSecretCredentialBuilder()
                .clientId(clientId).tenantId(tenantId).clientSecret(clientSecret).build();

        if (null == scopes || null == credential) {
            System.out.println("error");
        }

        final GraphServiceClient graphClient = new GraphServiceClient(credential, scopes);

        String fileStorageContainerId = ""; //put the driveId Of a user Here


		//works as intended
        graphClient.
                storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).drive();


		//will return an error
        RecycleBinItemCollectionResponse result =
                graphClient.
                storage().fileStorage().containers().byFileStorageContainerId(fileStorageContainerId).recycleBin().items().get();

		
        System.out.println("");
    }

}
SDK Version

6.29.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

error 400

Method threw 'com.microsoft.graph.models.odataerrors.ODataError' exception.
com.microsoft.graph.models.odataerrors.ODataError: One of the provided arguments is not acceptable.

Configuration

No response

Other information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documented recycle-bin endpoint and the GraphServiceClient call in the complete Java example, then reproduce the 400 response using the stated application permission and SDK version 6.29.0. Compare the request for the recycle-bin items entry point with the working drive request; done means identifying whether the failure is in the SDK request or the service/API behavior and recording the evidence.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.