I have the following code snippet. A slightly modified version of the sample code provided with the Xamarin Sitecore Extension.
var requesttwo = ItemWebApiRequestBuilder.ReadItemsRequestWithSitecoreQuery("select * from /sitecore/content/Home//*[@@TemplateName='Article']")
.AddFieldsToRead(new string[3] { "Title", "Author", "Content" })
.AddScope(ScopeType.Self)
.Build();
ScItemsResponse response = null;
try
{
// And execute it on a session asynchronously
response = await session.ReadItemAsync(requesttwo);
}
catch (Exception e)
{
String error = e.Message;
}
It works as expected when I replace
ReadItemsRequestWithSitecoreQuery("select * from /sitecore/content/Home//*[@@TemplateName='Article']")
with
ReadItemsRequestWithPath("/sitecore/content/home")
but the above block throws "[Sitecore Mobile SDK] Data from the internet has unexpected format." I found this question and I do recognize that sitecore queries use "@" but I added the below snippet as it seems to suggest and I get the same response.
string format = HttpUtility.HtmlEncode("select * from /sitecore/content/Home//*[@@TemplateName='Article']");
I figured out the problem. The below code works as expected.
I just had to remove the "select * from". I imagine AddFieldsToRead is appending its own select statement which was making the request "select foo bar from select * from" or something of the like. Just removing that part from the query gets me a proper response.
The clue was in this document. The bottom example only shows a sitecore path as opposed to a full query.