[TOC]
Request: Graph API query with startswith method and incorrect attribute name (userPrinicipalName - note the 'i' after 'n' in principal)
https://graph.windows.net/<tenant>.onmicrosoft.com/users?api-version=1.6&$filter=startswith(userPrinicipalName,'<username>')
HTTP Response: 400 Bad Request
{
"odata.error": {
"code": "Request_UnsupportedQuery",
"message": {
"lang": "en",
"value": "Unsupported method 'StartsWith' in query."
}
}
}
Observation/Issue: Correct result but misleading error message - Unsupported method 'StartsWith' in query. whereas the error must revert an attribute not found error.
Note: This issue seemd to affect all API versions from 1.5 onwards (tried 1.5, 1.6 and beta). API version '2013-11-08' does not have this bug. See section 'Filters using old API versions'.
The error when the ODATA query has startswith must be the same as one when using an equality search such as below.
Request: Graph API query without a method (search for attribute directly) and the same incorrect attribute name (userPrinicipalName)
https://graph.windows.net/<tenant>.onmicrosoft.com/users?api-version=1.6&$filter=userPrinicipalName eq '<username>@<domain>'
HTTP Response: 400 Bad Request
{
"odata.error": {
"code": "Request_UnsupportedQuery",
"message": {
"lang": "en",
"value": "Property 'userPrinicipalName' does not exist as a declared property or extension property."
}
}
}
Observation: Correct result and appropriate error message - Property 'userPrinicipalName' does not exist as a declared property or extension property.
Request: Graph API query with startswith method and incorrect attribute name (userPrinicipalName - note the 'i' after 'n' in principal)
https://graph.windows.net/<tenant>.onmicrosoft.com/users?api-version=2013-11-08&$filter=startswith(userPrinicipalName,'<username>')
HTTP Response: 400 Bad Request
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Could not find a property named 'userPrinicipalName' on type 'Microsoft.WindowsAzure.ActiveDirectory.User'."
}
}
}
Observation: The typo seems to give an appropriate indicator in the old versions of the API and this behaviour seems to have flipped in the later versions