Cloudrail - OneDrive API: Advanced search query not working

I am using cloudrail Node.Js v2.17.3.

I need to make an advanced request to OneDrive API.

The authentication part and getting / storing credentials succeeded. Here is the request I have to fulfill (according to the OneDrive doc): / drive / root / search (q = 'IMG_001.jpg')

Of course the file is present in my OneDrive account.

Here is the code:

const req = new cloudrail.types.AdvancedRequestSpecification("/drive/root/search(q='IMG_001.jpg')");
req.setMethod("GET");
req.setHeaders({"Content-Type": "application/json"});
service.advancedRequest(req, (err, res) => {
   console.log(err, res);
});

      

Err.message says "Invalid API or resource".

However, when I try a simple query "/ drive / root / children" it works ...

Thanks in advance.

+3


source to share


1 answer


Microsoft recently introduced its new Graph API, which I know is used by all services. So the documentation you are linking to is for the new API. Try using '/ drive / items / {the_folder_id or root} /view.search?q=txt' instead. You may also need a URL to encode the parameter. So a safe solution would probably be like this:



const url = "/drive/items/root/view.search?q=" + encodeURIComponent("[search query]");
const req = new cloudrail.types.AdvancedRequestSpecification(url);
req.setMethod("GET");
service.advancedRequest(req, (err, res) => {
    console.log(err, res);
});

      

+2


source







All Articles