Reputation: 557
I am currently implementing a Webhook with the Graph SDK and have a little problem/inconvenience. I am subscribing to calendar events of a user resource like this:
var request = GraphClientInitializer.Instance.GraphClient.Subscriptions.Request();
var result = await request.AddAsync(
new Subscription
{
ChangeType = WebhookConsts.SubscriptionChangeType,
NotificationUrl = WebhookConsts.SubscriptionNotificationUrl,
Resource = "/users/" + UserMail + "/" + "events",
ExpirationDateTime = DateTimeOffset.Now.AddMinutes(20),
ClientState = WebhookConsts.SubscriptionIdentifier
}
);
I receive notifiactions and i can read the messages sent to the notification url, but there doesn't seem to be an object in the SDK which parses received notifications.
Currently i am doing it myself:
public class Notification
{
[JsonProperty("value")]
public List<NotificationValue> Values { get; set; }
}
public class NotificationValue
{
[JsonProperty("subscriptionId")]
public String SubscriptionId { get; set; }
[JsonProperty("subscriptionExpirationDateTime")]
public String SubscriptionExpirationDateTime { get; set; }
[JsonProperty("clientState")]
public String ClientState { get; set; }
[JsonProperty("changeType")]
public String ChangeType { get; set; }
[JsonProperty("resource")]
public String Resource { get; set; }
[JsonProperty("resourceData")]
public NotificationResourceData ResourceData { get; set; }
}
public class NotificationResourceData
{
[JsonProperty("@odata.type")]
public String ODataType { get; set; }
[JsonProperty("@odata.id")]
public String ODataId { get; set; }
[JsonProperty("odata.etag")]
public String ODataEtag { get; set; }
[JsonProperty("Id")]
public String Id { get; set; }
}
Is there an object i can use for this or any other way i can implement it in the Graph SDK.
Upvotes: 6
Views: 997
Reputation: 1141
UPDATE: This functionality was implemented in the PR #1053 and now it is available through the class ChangeNotificationCollection.
Upvotes: 3
Reputation: 596
This functionality does not currently exist in the SDK. The SDK is generated based on the metadata provided by the API service (https://graph.microsoft.com/v1.0/$metadata) and the notification object is not defined there.
I believe this would make a great extension to the library. Would you be willing to open a pull request to the Microsoft.Graph Models>Extensions
folder? This would allow others to make use of the notification class you've created.
Upvotes: 1