Hi,
I am trying to fetch all the user from SharePoint online(Office 365) User profile in SharePoint App Part(Client web part).
My code is
| function getAllUsers() { //alert('GetallUserExecuted..'); var ctx = new SP.ClientContext(appWebUrl);//Get the SharePoint Context object based upon the URL var appCtxSite = new SP.AppContextSite(ctx, hostWebUrl); var web = appCtxSite.get_web(); //Get the Site //Textbox value containing search term var searchTerm = $("[Id*='peoplePickerDiv_TopSpan_i:0#.f|membership|'][Id*='_ProcessedUser']")[0].id.split('|')[2].split('_')[0]; clientContext = new SP.ClientContext.get_current(); //Building Keyword query for the search var keywordQuery = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(ctx); keywordQuery.set_queryText(searchTerm); keywordQuery.set_sourceId("B09A7990-05EA-4AF9-81EF-EDFAB16C4E31"); keywordQuery.set_rowLimit(500); keywordQuery.set_trimDuplicates(false); var searchExecutor = new Microsoft.SharePoint.Client.Search.Query.SearchExecutor(ctx); results = searchExecutor.executeQuery(keywordQuery); ctx.executeQueryAsync(onQuerySuccess, onQueryError); } function onQuerySuccess() { var testing = results.m_value.ResultTables[0]; $.each(results.m_value.ResultTables[0].ResultRows, function () { users.push(this.AccountName); }); fetchProfilePropertiesForUsers(); } function onQueryError(sender, args) { alert(args.get_message()); } |
This code is working for SharePoint hosted app but can't work on App Part or Client web part.
If i used this code in App Part its getting error Invalid Request.
Please suggest me Where I am doing mistake.
Thanks
Akash Anand

Manpreet SinghPosted Jan 5, 2015, 5:32 PM
Check my article here it might help you.
Url :- http://www.c-sharpcorner.com/UploadFile/644e54/user-profile-service-in-sharepoint-2013/
Cheers,
Manpreet