6

I am hoping to save someone some time as I couldn't find anyone talking about this anywhere.

I am looking at the SharePoint 2013 Search Rest API documentation and decided to switch my GET calls to POST to clean up code and allow for more complicated queries I foresee having to write.

Looking at this article, I build the queries to send to /_api/search/postquery.

After building a query similar to my GET one:

{ __metadata : {'type' : 'Microsoft.Office.Server.Search.REST.SearchRequest'}, 'Querytext':'alan', 'SelectProperties': { 'results':['Title,PictureURL'] }, 'rowlimit':5, 'SourceId': 'b09a7990-05ea-4af9-81ef-edfab16c4e31' } 

And solving this interesting issue.

I am now getting an error:

The parameter __metadata does not exist in method postquery

What am I missing?

1 Answer 1

11

The correct format for the Rest API POST Search Query is:

{ 'request': { '__metadata' : { 'type' : 'Microsoft.Office.Server.Search.REST.SearchRequest' }, 'Querytext': 'query' } } 

I found an example here in the second image.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.