sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

spHttpUtility.get() with search query returns Error: Microsoft.SharePoint.Client.UnknownError

Open MartinHatch opened this issue 7 years ago • 5 comments

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.

MartinHatch avatar Jul 30 '19 11:07 MartinHatch

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

msft-github-bot avatar Jul 30 '19 11:07 msft-github-bot

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.

bcameron1231 avatar Jul 30 '19 23:07 bcameron1231

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.

MartinHatch avatar Jul 30 '19 23:07 MartinHatch

Ah, alright.

Well glad to hear you got it resolved!

bcameron1231 avatar Jul 30 '19 23:07 bcameron1231

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

msft-github-bot avatar Jan 24 '20 00:01 msft-github-bot