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

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
941 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,195 questions
{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