Accessing Microsoft Graph API

Hi Node-Redders,

I am wondering if I can access the Microsoft Graph API with a function-node and a http-request node. I followed some guides on how to create an access token on https://portal.azure.com/ and I think I logged in correctly. But the return is payload.error.code = itemNotFound. Not sure if this is due to privileges. If so do I have to provide scopes somehow ... I am a little bit lost here ...

Is this even possible that way and how would I construct a function-node for a proper call? I hope some of you can point me in the right direction! Thanks in advance!

This is basicly the first attempt I tried to get a simple GET-request for OneDrive going

[...]
msg.url = "https://graph.microsoft.com/v1.0/me/drive/root/children";

msg.method = "GET";

msg.headers = { "Authorization": "Bearer " + msg.accesstoken, "Content-Type": "application/json"};

return msg;

Your code looks fine (but you don't show what else is in your flow or http request settings so cannot say for certain). Note: the URL, method and headers can all be set in the http request node instead (no-code style)

As for setting scope: can you point to an article that state where this "scope" setting should be in the request (and what type of values it expects)?

not sure if this thread is helpfull for you but the best I can provide https://learn.microsoft.com/en-us/answers/questions/28515/microsoft-graph-api-oauth-2-0-scopes

Also I want to download, upload, read files and so on ... thats why I would like to have full controll over the msg I provide to the http-request-node.

Maybe this helps? node-red-contrib-graph-oauth-login (node) - Node-RED

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.