Microsoft.Office.Server.Search.REST.SearchServiceException

%3CLINGO-SUB%20id%3D%22lingo-sub-2043069%22%20slang%3D%22en-US%22%3EMicrosoft.Office.Server.Search.REST.SearchServiceException%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2043069%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20Ladies%20and%20Gentlemen%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20receive%20this%20Exception%3A%3C%2FP%3E%3CP%3EMicrosoft.Office.Server.Search.REST.SearchServiceException%3C%2FP%3E%3CP%3Ewhen%20I%20try%20to%20execute%20following%20code%20in%20SharePoint%20Framework%20in%20SharePoint%20on%20premise%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Elet%20restApiUrl%3A%20string%20%3D%20context.pageContext.web.absoluteUrl%20%2B%20%22%2F_api%2Fsearch%2Fquery%3Fquerytext%3D'Test'%22%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Elet%20config%3A%20SPHttpClientConfiguration%20%3D%20new%20SPHttpClientConfiguration(%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20defaultODataVersion%3A%20ODataVersion.v3%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D)%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Econtext.spHttpClient%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.get(restApiUrl%2C%20config%2C%20%7B%20headers%3A%20%7B%20Accept%3A%20%22application%2Fjson%3Bodata%3Dminimalmetadata%3Bcharset%3Dutf-8%22%7D%7D)%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20.then((response%3A%20SPHttpClientResponse)%20%3D%26gt%3B%20%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWith%20best%20regards%3C%2FP%3E%3CP%3ELadislav%20Stupak%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Dear Ladies and Gentlemen,

 

I receive this Exception:

Microsoft.Office.Server.Search.REST.SearchServiceException

when I try to execute following code in SharePoint Framework in SharePoint on premise:

 

let restApiUrl: string = context.pageContext.web.absoluteUrl + "/_api/search/query?querytext='Test'";

 

let config: SPHttpClientConfiguration = new SPHttpClientConfiguration({

        defaultODataVersion: ODataVersion.v3

    });

 

context.spHttpClient

        .get(restApiUrl, config, { headers: { Accept: "application/json;odata=minimalmetadata;charset=utf-8"}})

        .then((response: SPHttpClientResponse) => {

 

Thank you for your help.

 

With best regards

Ladislav Stupak

0 Replies