SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.02k forks source link

Getting status: 500 on search api query #8918

Open mikezimm opened 1 year ago

mikezimm commented 1 year ago

I have been trying to build a simple search query from my spfx web part and am always getting an error 500 when using this api:

This is the documentation I am using as a reference: https://learn.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#sample-get-request

http://{server}/_api/search/query?querytext='sharepoint'

I've tried it with and without 'options' without any success. I also tried other endpoints in the docs such as _api/web/title and that works fine. So I'm not sure if it is me or a bug with the search endpoint.

One thing worth mentioning: If I just copy the full endpoint and paste into a new chrome browser address bar, I do get results in xml format. So that method works. Just not when calling it from a web part.

This is my sample code shown in the screenshot which gives the error:

https://github.com/mikezimm/aHubSearch/blob/6c8a7a0bf3fc34a55f15fd30ae2b685e4ea7b790/src/webparts/assocSites/components/AssocSites.tsx#L86

This is my sample web part and where it rejects:

image

This is the response at that point:

image


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.