I want to create a list alert using the rest endpoint _api/web/alerts/add
. For this I build a JSON-string representing an AlertCreationInformation
-object.
I tested this AlertCreationInformation
-object using CSOM Web.Alerts.Add()
and it works perfectly. But when POSTing this to _api/web/alerts/add
things break.
Headers:
{
"Accept ": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}
Payload:
{
"AlertFrequency": 2,
"AlertTemplateName": "SPAlertTemplateType.WebPageLibrary",
"AlertType": 2,
"AlwaysNotify": "true",
"DeliveryChannels": 1,
"EventType": 1,
"Filter": "<Query><And><Or><Eq><FieldRef Name=\"SomeField\"/><Value type=\"string\">Word</Value></Eq><Eq><FieldRef Name=\"SomeField\"/><Value type=\"string\">Excel</Value></Eq></Or><Or><Eq><FieldRef Name=\"SomeSkill\"/><Value type=\"string\">2 - Fortgeschritten</Value></Eq></Or></And></Query>",
"List": "3b80d325-4031-4de5-ae7f-5f6dd5f86b72",
"Title": "My Filtered Notification",
"User": 6
}
Error:
{
"status": 400,
"message": "The parameter \"AlertFrequency\" does not exist in the method \"Add\".\r\nclientRequestId: 77c80643-3a85-4c9e-8692-a3e19dafa988\r\nserviceRequestId: 02d5e69e-607c-8000-893a-517bd9aa37e8",
"source": "https://mytenant.sharepoint.com/sites/somesite/_api/web/alerts/add",
"errors": [
"-1",
"Microsoft.SharePoint.Client.InvalidClientQueryException"
]
}
The error-message always cites the first parameter in the JSON-object when I change the order. I also tried adding the property "__metadata": { "type": "SP.AlertCreationInformation" }
or wrapping the AlertCreationInformation object inside { "parameters": { .. object here ... }
. Still the same error, just referencing the properties __metadata
or parameters
.
How do I get this working?