I have provided some useful REST calls on the
SharePoint user profile in this blog post, I hope these calls may help someone.
Note: Replace "siteurl" with
your site url.
For more REST calls on user profiles, check this User profiles REST API reference
For more REST calls on user profiles, check this User profiles REST API reference
Calls Related to User Profile:
1 1. Get people followed by you:
2 2. Get people you are following:
3 3. To get current user profile properties:
4. To get properties of specific user:
https://siteurl/_api/SP.UserProfiles.PeopleManager/GetPropertiesFor(accountName=@v)?@v=’i:0%23.f|membership|test@onlinemicrosoft.com’
5. To get all employees in user profile:
6. Search employees by department :
https://siteurl/_api/search/query?querytext=’Department:IT*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31’&selectproperties=’LastName,FirstName,WorkEmail,JobTitle,PictureUrl,PreferredName,Department,AccountName’
Example Ajax calls:
GET:
$.ajax({
url: provideUrlHere,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
cache: false,
async: false,
success: function (data) {
//Do some thing with response data
},
error: function (data) {
// Request didn't succeed
}
});
POST
S$.ajax({
url: provideUrlHere,
type: "POST",
contentType: "application/json;odata=verbose",
data: data,
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": S$("#__REQUESTDIGEST").val()
},
success: function (data) {
//Do some thing with response data
},
error: function (data) {
// Request didn't succeed
}
});