I am trying to get multiple documents from CosmosDB by passing array of ids. This is the exception I get:
Message: {"errors":[{"severity":"Error","location":{"start":88,"end":88},"code":"SC1002","message":"Syntax error, unexpected end-of-file."}]}, Windows/10.0.19043 documentdb-netcore-sdk/2.11.2
Here is my code ( I tried different ways of passing the parameters) :
IList<string> ids = new List<string>();
ids.Add("8D5E4144");
ids.Add("A5964F");
ids = devices.Select(x => x.DeviceId).ToList();
SqlQuerySpec spec2 = new SqlQuerySpec
{
QueryText = "SELECT * FROM c WHERE (c.ttId = @tId And array_contains(@deviceids, c.deviceId)",
Parameters = new SqlParameterCollection()
{
new SqlParameter("@tenantId", tId.ToString()),
new SqlParameter("@deviceids", ids)
}
};
IDocumentQuery<DeviceDBSchema> devicesQuery2 =
CreateDocumentQuery<DeviceDBSchema>(
sqlQuerySpec: spec2,
feedOptions: new FeedOptions()
{
MaxItemCount = (int?)maxResponseCount,
PartitionKey = new PartitionKey(tId.ToString()),
RequestContinuation = continuationToken
}).AsDocumentQuery();
var devicesResults2 =
await devicesQuery2.ExecuteNextAsync<MySchema>(cancellationToken);
Any help or insights on how to fix this will be great. Thanks.
@tIdparameter however your parameter is named@tenantId. Is that a typo? 2) Why are you doingids = devices.Select(x => x.DeviceId).ToList();when you're creating a list ofidsbefore that? Also, as @MartinSmith said, you have a missing closing bracket. - Gaurav Mantri