$expand graph api call acting strange

Matt 0 Reputation points
2024-04-18T15:50:58.4366667+00:00

Hi,

I am making a call onto the Graph API using the $expand flag and I'm having issues with it. Note: I'm going to use the Microsoft provided api calls as an example.

Take the example from the site:

$expand=fields($select=Name,Color,Quantity)

My query returns a group in square brackets e.g $expand=fields($select=Name,[Color,Quantity]).

When i run this, I get an error An identifier was expected at position 5. I updated the select to use the HTML encoded square brackets to this - $expand=fields($select=Name,[Color,Quantity]) and then I get an another error complaining about unbalanced brackets. I don't see any unbalanced brackets in the query.

However, if I add a single bracket to the beginning on the $expand, the query will run fine.
($expand=fields($select=Name,[Color,Quantity]). This seems strange to me as there is now an unbalanced bracket but the query works fine.

Does anyone know what the correct syntax for this should be or why it behaves like this?

Thanks.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,616 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Danstan Onyango 3,741 Reputation points Microsoft Employee
    2024-04-24T16:35:08.5666667+00:00

    Expand Operator is documented here expand parameter which explains how the operator works.

    Ther query should work with balanced brackets. I was not able top produce a working Graph Query with unbalanced brackets. Take the query below:

    GET /groups?expand=members($select=id,userPrincipalName,displayName)

    Its a valid query and thats how the expand operator should work. If you have a complete query that behaves differently, please share with us including request id and timestamp in headers to help track.

    0 comments No comments