How to access search service api to get results in JSON format in asp.net web application outside SharePoint farm. It should be an app or SharePoint hosted.
I have tried the same with the help of "http://dotnetmafia.com/blogs/dotnettipoftheday/archive/2013/04/09/how-to-query-sharepoint-2013-using-rest-and-javascript.aspx".
function onQuerySuccess(data) {
var results = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
$("#resultsDiv").append('<table>');
$.each(results, function () {
$("#resultsDiv").append('<tr>');
$.each(this.Cells.results, function () {
$("#resultsDiv").append('<td>' + this.Value + '</td>');
});
$("#resultsDiv").append('</tr>');
});
$("#resultsDiv").append('</table>');
}
But we are getting data.d as undefined.
I have checked and verify that I am getting success and data in XML format not in JSON. As I expected the JSON. Although I have specified the "JSON" in headers " headers: { "Accept": "application/json; odata=verbose" } ".
Thanks
- Edited by Basant Pandey 1 hour 31 minutes ago