0

I'm doing this tutorial https://learn.microsoft.com/en-us/graph/tutorials/azure-functions, everything works fine when i use ngrok but if i replace ngrok value with my azure url app function, i get an error in the createdSubscription variable

var subscription = new Subscription
                {
                    ChangeType = "created",
                    NotificationUrl = $"{notificationHost}/api/Notify",
                    Resource = $"/users/{payload.UserId}/mailfolders/inbox/messages",
                    ExpirationDateTime = DateTimeOffset.UtcNow.AddHours(5),
                    ClientState = Notify.ClientState
                };

                // POST /subscriptions
                var createdSubscription = await graphClient.Subscriptions
                    .Request()
                    .AddAsync(subscription);

saying this System.NullReferenceException: 'Object reference not set to an instance of an object.', as i said before if i use ngrok everything works but if i use my azure url, no

Clerk tes
  • 1
  • 3
  • (1) share the detailed error response that you receive along with timestamp, requestid (2) Test the above outside of code and see still you can repro the issue in POSTMAN/Graph explorer as well – Dev Aug 12 '21 at 18:48

1 Answers1

0

The message "Object not set to an instance of Object" means you are trying to use an object which has not been initialized. This boils down to one of these:

  • Your code declared an object variable, but it did not initialize it (create an instance or 'instantiate' it)
  • Something which your code assumed would initialize an object, did not
  • Possibly, other code prematurely invalidated an object still in use

Check the SO for detailed information.

IpsitaDash-MT
  • 1,326
  • 1
  • 3
  • 7