microsoftgraph / msgraph-sdk-go

Microsoft Graph SDK for Go
https://docs.microsoft.com/en-us/graph/sdks/sdks-overview
MIT License
235 stars 36 forks source link

Cannot expand OneDrive facet when iterating over Users #704

Closed bartek closed 4 months ago

bartek commented 4 months ago

This may be expected, but the error I received was surprising and feels like it should not be presented to the user for this particular request.

The request I made and response:

{
  "url": "https://graph.microsoft.com/v1.0/users?$expand=drive",
  "method": "GET",
  "status": 400,
  "header": {
    "Client-Request-Id": [
      "94fdfed8-5405-44a1-a548-6359fc475e00"
    ],
    "Content-Type": [
      "application/json"
    ],
    "Date": [
      "Wed, 08 May 2024 13:05:47 GMT"
    ],
    "Request-Id": [
      "e7d5ccef-9379-4c12-8833-106cdebddcef"
    ],
    "Strict-Transport-Security": [
      "max-age=31536000"
    ],
    "Vary": [
      "Accept-Encoding"
    ],
    "X-Ms-Ags-Diagnostic": [
      "{\"ServerInfo\":{\"DataCenter\":\"East US\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"003\",\"RoleInstance\":\"BL6PEPF0000C451\"}}"
    ]
  }
  "body": {
    "error": {
      "code": "BadRequest",
      "message": "User ID cannot be empty or whitespace.",
      "innerError": {
        "date": "2024-05-08T13:05:48",
        "request-id": "e7d5ccef-9379-4c12-8833-106cdebddcef",
        "client-request-id": "94fdfed8-5405-44a1-a548-6359fc475e00"
      }
    }
  }
}

What I was trying to do was expand the OneDrive facet when iterating over users to more efficiently obtain this data, however it does not seem possible with $expand or $select

The error message, User ID cannot be empty or whitepace is not clear and seems to be surfacing due to an internal bug within the MS Graph API, rather than the user's request.

Or am I using expand incorrectly here?

Thanks!

rkodev commented 4 months ago

Hi @bartek thanks for trying this out. I'll start by pointing out that this is a service layer error and not an SDK error. Your syntax however seems to be attempting to expand relationships as opposed to the properties. Proper use would be to use $select and $expand with properties

bartek commented 4 months ago

@rkodev Thanks for the pointer. This clarifies to me that I am unable to expand relationships without further selection. I'll close the issue