1

I am trying to query for a Sitecore item where a particular field has a particular value but am not successfull in doing so.

I am trying to do http://sc8/-/item/v1/?query=/sitecore/content/Home/*[@Title=#Welcome to Sitecore#]

The response I am getting is { "statusCode": 400, "error": { "message": "Bad Sitecore query (/sitecore/content/Home/*[@Title)." } }

Can any one correct me please?

1

1 Answer 1

6

I believe the problem is the hash (#) signs instead of quotes (') around values.

This is a sample query from the Item Web API documentation:
/sitecore/content/Home/*[@Title='Welcome to Sitecore']

Documentation link (old, but I could not find any more recent): https://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc65-66-usletter.pdf

Hash (#) signs are used to escape item names in the path and field names when they contain protected characters and words:
/sitecore/content/Home/#our-products#/*[@#category-type#='something']

See e.g. these links for more details on the query syntax: https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/sitecore-query-cheat-sheet https://sdn.sitecore.net/Reference/Using%20Sitecore%20Query/Sitecore%20Query%20Syntax.aspx

Your Answer

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

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