Forum Discussion

Paul Summers's avatar
Paul Summers
Icon for Microsoft rankMicrosoft
Sep 07, 2016

Use SharePoint Framework and Search API

I am trying to build a search-driven app using the new SharePoint Framework. Whenever I use the built-in HTTP client, I get a 500 error for search. The same GET request runs fine in the same browser session. I've run through SP framework tutorials on GitHub and the list requests work fine (in the same app) but search continues to return a 500 error.

 

Any pointers?

 

Here's a sample of my function trying to call search...

 

protected get searchHttpClientOptions(): IHttpClientOptions {
return {
headers: {
'Accept': 'application/json;odata=verbose',
'Content-Type': 'application/json;odata=verbose'
}
};
}
private _getSearchResults(): Promise<SPResults> { const httpOptions: IHttpClientOptions = this.searchHttpClientOptions; return this.context.httpClient.get(this.context.pageContext.web.absoluteUrl + `/_api/search/query?querytext='the'`, httpOptions) .then((response: Response) => { return response.json(); }); }

 

Resources