Catch OneDrive notifications through socketio

Jareth Lomson 1 Reputation point
2022-11-12T08:55:55+00:00

Hi All!

I would like to catch notifications of changes that occur on my personnal OneDrive Storage with a nodeJs code.
I followed the steps provided by the documentation here :

1 - Retrieve the notification URL with the request
GET https://graph.microsoft.com/v1.0/me/drive/root/subscriptions/socketIo

2 - Catch notifications with the following nodejs ( v16.17.1) script launched from an on-premise server:

io = require("socket.io-client")  
  
var notificationUrl = "<notificationURL_retrieved_from_the_first_request>"  
  
var socket = io(notificationUrl);  
socket.on("connect", () => console.log("Connected!"));  
socket.on("connect_error", (data) => console.log("Connect Error:", data));  
socket.on("notification", (data) => console.log("Notification!", data));  

Result is the following error:

Connect Error: TransportError: xhr poll error

What is missing ?
Thanks

Jareth

Microsoft 365 and Office Development Office JavaScript API
Microsoft 365 and Office OneDrive For business Windows
{count} votes

1 answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.