3

I'm using cloudrail Node.Js v2.17.3.

I have to do an advanced request on OneDrive API.

The authentication part and getting/storing credentials have succeeded. Here is the request I have to do (according to OneDrive's 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 the simple request "/drive/root/children", it works...

Thank you in advance.

4

1 回答 1

2

微软最近推出了他们的新 Graph API,据我所知,它被所有服务使用。因此,您所指的文档是针对新 API 的。尝试改用 '/drive/items/{the_folder_id 或 root}/view.search?q=txt'。您可能还需要对参数进行 url 编码。所以最安全的解决方案可能是这样的:

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);
});
于 2017-05-04T22:06:14.563 回答