1

I am trying to use stored Sitecore search using an API call from console application, but it is throwing 400 error. I have followed the sitecore documentation

https://doc.sitecore.com/xp/en/developers/102/sitecore-experience-manager/the-restful-api-for-the-itemservice.html

under the last section "Run a stored Sitecore search" section with the URL format provided. The URL which I provided is the following -

https://demosc.dev.local/sitecore/api/ssc/item/1FB673FA-C0E0-4174-BA8F-2C170BB71BCD/search?term=State&database=master

It seems the URL structure formed is not correct and I am not sure as I followed the example in the documentation. Kindly help me with the same.

1
  • Which Sitecore version you are using? Commented Oct 7, 2022 at 14:43

1 Answer 1

1

I have tried running this query via Postman and the syntax seems fine to me. Just follow the below steps to make this work.

  • First of all, You will need to use this method to authenticate users. It sets the authentication cookie.
    https://<your server>/sitecore/api/ssc/auth/login

enter image description here

Make sure you are passing, Content-Type:application/json in the headers.

  • Now, Use the below query to run a Sitecore search that is stored in a search definition item. This means you will need to first create a Search definition item in the Sitecore content tree based on the template /sitecore/templates/System/Services/Item Service/Search/Search Definition. You can provide details for this item like database, field name etc.

enter image description here

Now, run the query on this item,

<your server>/sitecore/api/ssc/item/FDFFA0FA-40D4-47F6-87CD-7BC3B1EA6EC2/search?term=Home&database=master

enter image description here

In the result, you would see all the items having search terms in the defined fields

1
  • Hi, Thanks for the help. It worked like magic. I am able to check the same in postman. But I have one doubt. So this stored search query is to search items only inside any field. For ex, the content inside a rich text editor/single line text or will it retrieve even content items also? Because if it fetches the content items there is another search type called "Run a Sitecore search" which retrieves content items based on search term. so just wanted to understand in which case scenario both needs to be differentiated? Commented Oct 10, 2022 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.