spHttpUtility.get() with search query returns Error: Microsoft.SharePoint.Client.UnknownError
Category
- [ ] Question
- [ ] Typo
- [X] Bug
- [ ] Additional article idea
Expected or Desired Behavior
When using spHttpClient to retrieve a response from the SharePoint search REST API, the correct JSON response value should be returned.
Example URL:
/_api/search/query/queryText='foo'&selectproperties='Title,Path'&rowlimit=5
Observed Behavior
The response in full:
{"error":{"code":"-1, Microsoft.SharePoint.Client.UnknownError","message":"Unknown Error"}}
Steps to Reproduce
Make a call to:
this.context.spHttpClient.get
Passing in a valid SharePoint search query.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Can you provide a bit more information? I'm trying to understand what you are trying to do.
SPHttpUtility is an OM class used for encoding/working with URLs.
Are you trying to use spHttpClient?
Some clarity would be helpful.
Gah .. typo sorry!
Yes this was spHttpClient
I have actually resolved this, I had to force the OData version headers back to v3 instead of v4 as the search API doesn't support v4.
It would be useful if the client identified /_api/search as being the target endpoint and adjusted the headers automatically.
Ah, alright.
Well glad to hear you got it resolved!
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues