I have set up a search using the rest api on SharePoint. I can get back a json object with the results, however, I am having a hard time getting to the data I want in the JSON object. I want specific fields from the PrimaryQueryResult specifically the Title, Author, Size, and Path. Here is the code I am hacking at to try and get this:
HttpWebRequest endpointRequest = (HttpWebRequest)HttpWebRequest.Create(@"https://oursites.myngc.com/TS/EDMS/_api/search/query?querytext='(tequila)'"); endpointRequest.Method = "GET"; endpointRequest.Accept = "application/json; odata=verbose"; endpointRequest.UseDefaultCredentials = true; HttpWebResponse endpointResponse = (HttpWebResponse)endpointRequest.GetResponse(); Stream webStream = endpointResponse.GetResponseStream(); StreamReader responseReader = new StreamReader(webStream); string response = responseReader.ReadToEnd(); JObject jobj = JObject.Parse(response); JArray jarr = (JArray)jobj["d"]["query"]["PrimaryQueryResult"]["Relevantresults"]["Table"]["Rows"]["results"]; responseReader.Close();
I have tried a lot of different combination including using a path from an online JSON editor with no luck. Can someone help me zero in on these fields?