Please bear in mind that since Delve utilizes search internally, you will have to wait for a search crawl to take place in Office 365 before you can see results of the REST operation.
I have used JavaScript and the jQuery.ajax function to make calls to the Signals API. But you can use a variety of other options which support REST.
So without much further ado, here is the code to follow or unfollow a board in Delve:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
(function ($) { | |
$(document).ready(function () { | |
//Name of the board you want to follow or unfollow | |
var boardName = "My Delve Board"; | |
//Comment out the action which you don't want. I have commented Unfollow in this case. | |
var actionVerbValue = "Follow"; | |
//var actionVerbValue = "UnFollow"; | |
var signalData = { | |
"signals":[{ | |
"Actor":{ | |
"Id":null | |
}, | |
"Action":{ | |
"ActionType":"Follow", | |
"UserTime": new Date().toISOString(), | |
"Properties":{ | |
"results":[ | |
{ | |
"__metadata":{ | |
"type":"SP.KeyValue" | |
}, | |
"Key":"ActionVerb", | |
"Value":actionVerbValue, | |
"ValueType":"Edm.String" | |
} | |
] | |
} | |
}, | |
"Item":{ | |
"Id":"TAG://PUBLIC/?NAME=" + boardName | |
}, | |
"Source":"VrdmnOfficeGraphApp" | |
}] | |
}; | |
var requestHeaders = { | |
"Accept": "application/json;odata=verbose", | |
"X-RequestDigest": jQuery("#__REQUESTDIGEST").val() | |
}; | |
jQuery.ajax({ | |
url: _spPageContextInfo.webAbsoluteUrl + "/_api/signalstore/signals", | |
type: "POST", | |
data: JSON.stringify(signalData), | |
contentType: "application/json;odata=verbose", | |
headers: requestHeaders, | |
success: function (data) { | |
console.log(data); | |
}, | |
error: function (jqxr, errorCode, errorThrown) { | |
console.log(jqxr.responseText); | |
} | |
}); | |
}); | |
})(jQuery); |
No comments:
Post a Comment