# Accessing Microsoft Graph API

**URL:** <https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388>\
**Category:** General\
**Created:** [17 September 2023 07:46 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388 "2023-09-17T07:46:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tfuchs1987](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tfuchs1987/32/44508_2.png) [@tfuchs1987](https://discourse.nodered.org/u/tfuchs1987)\
**Post date:** [17 September 2023 07:46 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388/1 "2023-09-17T07:46:56Z")

</div>

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/](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

```auto
[...]
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;

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 September 2023 07:59 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388/2 "2023-09-17T07:59:51Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![tfuchs1987](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tfuchs1987/32/44508_2.png) [@tfuchs1987](https://discourse.nodered.org/u/tfuchs1987)\
**Post date:** [17 September 2023 08:06 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388/3 "2023-09-17T08:06:36Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [17 September 2023 08:11 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388/4 "2023-09-17T08:11:58Z")

</div>

Maybe this helps? [node-red-contrib-graph-oauth-login (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-graph-oauth-login)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 November 2023 08:12 UTC](https://discourse.nodered.org/t/accessing-microsoft-graph-api/81388/5 "2023-11-16T08:12:48Z")

</div>

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