- Links
- Graph Explorer
- MS Odata Document
- Oasis Odata v4.0.1 URL Conventions, specifically, pay attention to
- An Odata URL is consist of 3 parts
- root URL: GET request made to root URL returns service document (that defines all resources available via the service)
- resource path: Entity or entity sets that are accessible via RESTful API
- Query option: select, filter, count, skip, order, top etc. See next section
- Addressing
- Getting entity set: GET serviceRoot/users
- Getting individual entity by key: GET serviceRoot/users('john.doe@example.com')
- Getting entity property GET serviceRoot/users/displayName
- Getting entity property raw value: GET serviceRoot/users/displayName/$value
- Getting entity set: GET serviceRoot/users
- Getting entity set: GET serviceRoot/users
- Addressing metadata in powershell: $obj.'@odata.type'
The key here is that the dot (.) between "odata" and "type" is not denotation of a sub-property, but just a normal text character as part of the property name '@odata.type' (so we quote the whole string) - Query options
- Filter:
- Filter operators: eq/ne/gt/ge/lt/le/and/or/not/has/in
- Filter functions: contains/startsWith/endsWith/indexOf/concat/subString
- Collection functions: hasSubset/hasSubsequence
- More functions on Oasis URL above
- Example #1: GET serviceRoot/users?$filter=upn eq 'johnDoe@example.com'
- Example #2, filter against complex type. This query finds airports whose address contains "San Francisco", where address is a property of a complex type Location: GET serviceRoot/Airports?$filter=contains(Location/Address, 'San Francisco')
- Example #3: GET serviceRoot/users?$filter=upn in {upn1@x.com,upn2@x.com}'
- Expand:
- Navigation properties: any property that can link to another entity. For example, "memberof", "manager" property of a user
- Example #1: GET serviceRoot/users?$filter=upn eq 'johnDoe@example.com'$expand=manager
- Example #2: $uObj=get-mgUser ... -expandproperty manager; $uObj.manager.additionalProperties.displayName
- Example #3: get-mgUser ... -expandproperty "manager(`$select=displayName,jobTitle)"
- Select:
- Example #1: GET serviceRoot/users?$select=*
- OrderBy:
- Example #1: GET serviceRoot/users?$expand=manager($orderby=department)
- Example #2, order by the count of members: GET serviceRoot/groups?$orderby=members/$count
- Top/Skip/Count
- any/all operator
- GET serviceRoot/People?$filter=Emails/any(s:endswith(s, 'contoso.com'))
- Literals
- null/$it/$root/$this
- placeholder
Search This Blog
Showing posts with label graph. Show all posts
Showing posts with label graph. Show all posts
Jul 20, 2023
MS Graph RESTful Queries
Subscribe to:
Posts (Atom)