0

The Graph API isn't well documented about a few things, and so I was wondering if anyone had some insight, or direct answers to the following problem:

Background

I am attempting to create a RESTful API that interacts with the shared documents of a sharepoint site to automate much of the process.

I will be storing customer documents in a user folders. These folders are created using an identity (id/guid) style naming convention. Each file they create or are allocated are stored there. There may be duplicate names across customers.

I have created the C & D of CRUD, and with a microsoft ID can easily R (and download).

However, there are problems searching, and the microsoft documentation is far from complete.

Currently confirmed used routes

These are the routes I'm (successfully) using to do my operations:

(all with the prefix: https://graph.microsoft.com/v1.0/)

  • Root list - Get: {site_name}/drive/root/children
  • Create - PUT: {site_name}/drive/items/{parent_folder_id}:/content
  • Retrieve - GET: {site_name}/drive/items/{resource_id}/
  • Download : GET: {site_name}/drive/items/{resource_id}/content
  • Delete : DELETE: {site_name}/drive/items/{resource_id}

These are working as expected.

TLDR; The Specific questions:

How do I format request in order to search:

  1. view files in a folder
  2. limited to one folder
  3. limited to a search criteria

Question detail #1

There is no documentation I can find that shows to perform the list, but .. not at root level!

  • Root list - Get: {site_name}/drive/root/children

.. so what is the format to limit this search to a folder. Here's some pseudo-code that doesn't work:

  • Pseudo - Get: {site_name}/drive/{folder_name}/children
  • Pseudo - Get: {site_name}/drive/root/{folder_name}/children

Note: This is for the very common customer use case:

  • "Get all files owned by Joe Bloggs"

Question detail #2

Given that many files in different folders will have the same name, how do I format a search to be limited to a folder. The current suggested search criteria is as follows:

  • /search(q='{search_value')

If I run the following query, it runs at a root level:

  • Get: {site_name}/drive/root/children?search(q='{search_value')

How do I format this to be limited to a folder?

Question detail #3

Is there a way to limit the search criteria to search by a property? For example, to distinguish between the following:

  • File 1 Filename : abcdff.jpg
  • File 2 ID : abcdef ...

...or some such combination of metadata.

So using some psuedo-SQL type URL:

  • Get: {site_name}/drive/root/children?search(q='{name=search_value}')

Thanks in advance to all.

  • In your confirmed routes and pseudo code you are referencing the /drive/ path api. Are these libraries located within users’ OneDrive or in a regular SharePoint online document library? If your answer is the latter why not use the {site name}/_api/ REST endpoint and save yourself some undocumented grief? – A.k.A. Fritz Apr 11 at 4:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.