13,745 questions
How to Deserialize using JsonSerializer A ChangeNotification Collection Properly.?
Richard Simpson
0
Reputation points
using System.Text.Json;
using Microsoft.Graph.Models;
[HttpPost("lifeCycleNotifications")]
public async Task<ActionResult> HandleAsyncData([FromQuery] string? validationToken = null)
{
// handle validation
if (!string.IsNullOrEmpty(validationToken))
{
// Decode the validation token and return it
string decodedToken = HttpUtility.UrlDecode(validationToken);
return Content(decodedToken, "text/plain");
}
// handle notifications
using (StreamReader reader = new StreamReader(Request.Body))
{
string content = await reader.ReadToEndAsync().ConfigureAwait(false);
Console.WriteLine(content);
var notifications = JsonSerializer.Deserialize<ChangeNotificationCollection>(content);
//Here notifications is always null. Not having proper deserialization,
await this.subscriptionService.ResubcribeToNotifications(content);
}
return Ok();
}
Microsoft Security | Microsoft Graph
Sign in to answer