'Azure Cosmos Table API Rest API $filter InvalidInput

I am trying to query a Cosmosdb with a Table API with Postman and use OData.

I have a query which works for $top and $select - but returns Invalid Input when I try a filter.

so for the query.

https://{{databaseAccount}}.table.cosmos.azure.com:443/Rdm()?$filter=PartitionKey eq '726'

I get returned

{
    "odata.error": {
        "code": "InvalidInput",
        "message": {
            "lang": "en-us",
            "value": "Request url is invalid.\r\nActivityId: 3cf6769d-fe56-40ca-832d-305820ef78e1, documentdb-dotnet-sdk/2.14.0 Host/64-bit MicrosoftWindowsNT/10.0.19041.0\nRequestID:3cf6769d-fe56-40ca-832d-305820ef78e1\n"
        }
    }
}

Though the following will return me results:

https://{{databaseAccount}}.table.cosmos.azure.com:443/Rdm()?$top=1&$select=PartitionKey

Gives:

{
    "value": [
        {
            "odata.etag": "W/\"datetime'2022-01-01T14%3A07%3A54.8052493Z'\"",
            "PartitionKey": "8"
        }
    ]
}

Is there some weird little header that is required to do filtering?

Clearly Authorisation is working, otherwise headers sent are:-

Accept: application/json
x-ms-version: 2021-06-08
x-ms-date: Fri, 06 May 2022 17:14:30 GMT
Authorization: SharedKey {{databaseAccount}}:gargbagebutitdoesappeeartotherwisework
User-Agent: PostmanRuntime/7.29.0
Cache-Control: no-cache
Postman-Token: 0e09a9e8-210d-4b6f-a258-efe6963bff39
Host: {{databaseAccount}}.table.cosmos.azure.com:443
Accept-Encoding: gzip, deflate, br
Connection: keep-alive

The signature is composed of:

verb + \n + \n + \n + dateUtc + \n + /{{databaseAccount}}/{{table}}

where table in this case = Rdm()



Solution 1:[1]

Turns out I needed to add the header - MaxDataServiceVersion: 3.0;NetFx

Eventually found the answer in GitHub https://github.com/Azure/azure-sdk-for-go/issues/1020

It's also quite clearly stated in their documentation - doh.

https://docs.microsoft.com/en-us/rest/api/storageservices/setting-the-odata-data-service-version-headers

When you call one of these operations, you must specify the OData data service version, using one of the following request headers:

MaxDataServiceVersion, to specify the maximum data service version

DataServiceVersion, to specify the exact data service version

If both headers are present, precedence is given to MaxDataServiceVersion

Sources

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

Source: Stack Overflow

Solution Source
Solution 1