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"];


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?


1 Answer 1


Looks like a capitalization issue. Try "RelevantResults". Everything is case sensitive.

This is the path when using a JavaScript object:

  • That did it. Here is the path I finally ended up using to get to the results: (JArray)jobj["d"]["query"]["PrimaryQueryResult"]["RelevantResults"]["Table"]["Rows"]["results"][i]["Cells"]["results"]; where "i" is the row in the results to process.
    – john
    Jun 1, 2018 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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