Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
Onedrive list files in folder javascript

I am trying to list all files in a folder on my onedrive using ajax. Is there universal url for this or do I need to go through their picker? Like google drive url for example:

var url = "https://www.googleapis.com/drive/v3/files?q='" + FOLDER_ID + "'+in+parents&pageSize=1000&key=" + API_KEY

$.ajax({
        url: url,
        dataType: "jsonp"
    }).done(function(media) {

  
    }).fail(function(jqXHR, textStatus, errorThrown) {
    
    }); 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe your goal is as follows.

  • You want to retrieve the file list in the specific folder of OneDrive using ajax.

In this case, how about the following modified script?

Modified script:

In this modified script, the file list is retrieved from the specific folder using Graph API. In this case, the access token is required to be used. When the access token is not used, an error like InvalidAuthenticationToken occurs even when the folder is publicly shared. Please be careful about this.

const folderName = "### folder name ###";
const driveId = "### your drive ID ###";
const url = `https://graph.microsoft.com/v1.0/drives/${driveId}/root:/${folderName}:/children`;
const accessToken = "### your access token ###";
$.ajax({
  url: url,
  headers: {"Authorization": "Bearer " + accessToken}
}).done(function(media) {
  console.log(media)
}).fail(function(jqXHR, textStatus, errorThrown) {
});
  • Also, you can retrieve the file list from the other endpoint as follows. In this case, drive id is not used.

      const folderName = "### folder name ###";
      const url = `https://graph.microsoft.com/v1.0/drive/items/root:/${folderName}?expand=children`;
    

References:

  • Authentication and authorization basics for Microsoft Graph
  • Working with files in Microsoft Graph
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!