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:
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:
This is the response at that point:
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.