'Azure cosmos documentdb SQL API, distinct query through Rest API gives 400 error

When I post query through REST API to Azure cosmos documentdb which contains Distinct keyword gives following error Example of Request :

  curl --location --request POST  
https://accountname.documents.azure.com:443/dbs/cosmosdb/colls/collname/docs' \
--header 'Accept: application/json' \
--header 'x-ms-version: 2015-04-08' \
--header 'authorization: type%3Dmaster%26ver%3D2015-04-08%26sig%3Defesffssdvdvdfbgb10%3D' \
--header 'Content-Type: application/query+json' \
--header 'x-ms-documentdb-isquery: True' \
--header 'x-ms-documentdb-query-enablecrosspartition: True' \
--header 'x-ms-date: Fri, 22 Apr 2022 10:01:49 GMT' \
--data-raw '{
  "query": "SELECT distinct f.UseName from collname f "
}'

Response details:

{
    "code": "BadRequest",
    "message": "The provided cross partition query can not be directly served by the gateway. This is a first chance (internal) exception that all newer clients will know how to handle gracefully. This exception is traced, but unless you see it bubble up as an exception (which only happens on older SDK clients), then you can safely ignore this message.\r\nActivityId: d3aa3352-b957-437e-a259-9f1d48277342, Microsoft.Azure.Documents.Common/2.14.0"
}

The error message isolated:

"The provided cross partition query can not be directly served by the gateway. This is a first chance (internal) exception that all newer clients will know how to handle gracefully. This exception is traced, but unless you see it bubble up as an exception (which only happens on older SDK clients), then you can safely ignore this message.\r\nActivityId: d3aa3352-b957-437e-a259-9f1d48277342, Microsoft.Azure.Documents.Common/2.14.0"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source