0

I am trying to develop a SharePoint Online Add-in. I have a simple query that seems to get all of the Events the current user is authorized to see [1]:

var getEventsURL =
    "https://" + hostName + "/" + theSitePath +
    "/_api/search/query?" +
    "querytext='contenttype:Event'";

I run that query with a simple $.ajax call. When the results come back, I get an array of rows in data.d.query.PrimaryQueryResult.ReleventResults.TableRows.results [2]. When I open one of these rows, I see yet another array of 48 values in Cells.results that contains all of the data fields for that row.

In column 3, I see the Title for the current Event. Also in column 7, I see the Description [3]. That's very useful to me but I also need to find the StartDate and EndDate of the Event. Unfortunately, I've looked all through the 48 returned values for the currently iterated Event and I can't find StartDate or EndDate anywhere.

After running a Search Query of the form
https://[serverName]/_api/search/query?queryText='contenttype:Event';
how do I find the DateTimes at which each Event begins and ends?

[1] - Accessing list data in multiple site collections
[2] - http://michaelsoriano.com/understanding-sharepoint-rest-api-part-1-selecting-items/
[3] - Column numbers are zero based

  • When I run "querytext='ContentClass:STS_ListItem_Events'" in the SharePoint Search Query Tool and click the "View all properties..." button in the Primary Results tab, I see the EndDateOWSDATE and EventDateOWSDATE properties I need, but I'm still not finding them in data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results[index].Cells.results where I would expect them. – Shawn Eary Sep 4 at 15:32
0

I was able to retrieve the times the events started and stopped by referencing EndDateOWSDATE and EventDateOWSDATE via the selectProperties [1][2] query parameter. My resulting query is:

var getEventsURL =
    "https://" + hostName + "/" + theSitePath +
    "/_api/search/query?" +
    "querytext='ContentClass:STS_ListItem_Events'" +
    "&selectProperties=" +
    "'Title,Description,EndDateOWSDATE,EventDateOWSDATE'";

I also made some changes to the SharePoint Search Schema similar to what is mentioned in [3] but I'm not 100% sure that was necessary.

[1] - https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#bk_SelectProperties
[2] - https://social.technet.microsoft.com/Forums/Lync/en-US/3b2c39a3-8017-40c0-b866-e1efbf7104ad/how-do-i-query-all-the-managed-properties-available-for-search-results
[3] - https://social.msdn.microsoft.com/Forums/fr-FR/586d4eb5-e090-460e-892d-acfffd7ea489/calendars-fields-eventdate-and-enddate-does-not-appear-in-search-result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.