Unable to delete One Drive files using graph api

Copper Contributor

I am getting 403 error when trying to delete file from One Drive.

Steps I have taken:

Created App called OneDriveDeleete in Azure, with Delegated Access for 

Files.ReadWrite.All. Granted Admin consent. 
Created SPFX webpart with the following web api permission
"webApiPermissionRequests": [
        "resource": "OneDriveDelete",
        "scope": "Files.ReadWrite.All"
This API access was also approved in Sharepoint Admin center.
This is the code,
  constructor(props: IOneDriveDeleteProps) {
    this.state = {
      files: []
    .then((client: MSGraphClientV3) => {
      this.graphClient = client;
const handleDeleteClick = async (fileid: string):Promise<void> => {
  // Handle delete button click
try {
  // Ensure the graphClient is initialized
  if (!this.graphClient) {
    console.error('Graph client not initialized.');

  // Make a DELETE request to the Microsoft Graph API to delete the file
  const response = await this.graphClient.api(`/me/drive/items/0175NRJMNZV2ZMLXHYWJA3A7OPGDCOXKBJ`).delete();

  if (response.ok) {
    console.log('File deleted successfully.');
  } else {
    console.error('Error deleting file:', response.statusText);
} catch (error) {
  console.error('Error deleting file:', error);
Please help
1 Reply

Is this the right forum for this query? Is this forum active? Can somebody guide me to the right forum for this query?