Graph client library APIs can be categorized into Create, Query, Update, Delete and Other (custom actions) APIs.

Create

To create new object, set the required properties and use the “T Add<T>(GraphObject)” method. This method will return the object that is returned by the server (with the ObjectId and other server generated properties filled out). You cannot add any links as a part of Add or Update.

User userToBeAdded = new User(); 
userToBeAdded.DisplayName = "John Doe"; 
userToBeAdded.UserPrincipalName = userPrincipalName; 
userToBeAdded.AccountEnabled = true; 
userToBeAdded.MailNickname = userPrincipalName.Split("@".ToCharArray())[0]; 
userToBeAdded.PasswordProfile = new PasswordProfile(); 
userToBeAdded.PasswordProfile.Password = "P@ssw0rd!"; 
userToBeAdded.PasswordProfile.ForceChangePasswordNextLogin = false; 
userToBeAdded.UsageLocation = "US";  
userToBeAdded = graphConnection.Add<User>(userToBeAdded);
 

Get object with the key (objectId)

ObjectId is the key for all graph objects. To get all the properties of an object

User retrievedUser = graphConnection.Get<User>(userObjectId);

Update

To update an object, set the properties that need to be changed and call the Update method. The library will submit only the properties that were modified. ObjectId is required to be able to update any object. You cannot manipulate any links as a part of Update.

User retrievedUser = graphConnection.Get<User>(userObjectId); 
retrievedUser.City = “Redmond”;  
retrievedUser = graphConnection.Update(retrievedUser);
 

Delete

To delete an object, use Delete method by passing in the object to be deleted.

graphConnection.Delete(retrievedUser);

List and Search graph objects

To List method allows you to query for the list of objects. Below is an example to get all the users in your tenant.

PagedResults<User> users = graphConnection.List<User>(null, null);

The PagedResults will contain the list of users that were returned by the request along with “PageToken” (to request for next page of results) and the “IsLastPage” property (which indicates the availability of further results). To get the next page of results, call List API with the same parameters, plus the page token.

users = graphConnection.List<User>(users.PageToken, null);
while (!pagedResults.IsLastPage)
{
 pagedResults = graphConnection.List<User>(users.PageToken, null);
// use pagedResults.Results
}

Method overrides

If you know the type of Graph object during compile time, you can use the template methods. If not, you can pass the type of the entity and you will get results of type GraphObject.

PagedResults<GraphObject> users = graphConnection.List(typeof(User), null, null);

Filters

Filters like ==, <=, >= and StartsWith are supported. For multi-valued properties, you can do the conditional “Any” expression on the
values. Filter conditions can be joined together using And / Or operators.

Helper methods are available to create each part of the filter expression and join them. You also have the option of using a custom generated filter expression (instead of using the helper methods).

FilterGenerator filter = new FilterGenerator();
filter.QueryFilter = ExpressionHelper.CreateConditionalExpression(typeof(User), GraphProperty.UserPrincipalName, userPrincipalName, ExpressionType.Equal);
PagedResults<User> pagedResults = graphConnection.List<User>(null, filter);

You can combine multiple search filters using the AND, OR operators.

BinaryExpression displayNameExpression = ExpressionHelper.CreateStartsWithExpression(typeof(User), GraphProperty.DisplayName, "ab");
BinaryExpression cityExpression = ExpressionHelper.CreateEqualsExpression(typeof(User), GraphProperty.City, "Seattle");
filters.QueryFilter = ExpressionHelper.JoinExpressions(displayNameExpression, cityExpression, ExpressionType.And);

Sorting

Using the filter generator, you can specify the property on which the results should be sorted. Currently, secondary sort order cannot be specified.

The server may not support sorting / filtering of some entities / properties.

Automatic expansion of links

When listing objects, you can optionally expand a link, by using the Expand property in the filter generator. Only one link can be expanded with each request.

FilterGenerator filterGenerator = new FilterGenerator();
filterGenerator.ExpandProperty = LinkProperty.Manager;
PagedResults<User> users = graphConnection.List<User>(null, filterGenerator);
 

Navigating Links

Links can be single-valued or multi-valued. When navigating the linked objects, the results are paged. Here is an example to get a page of linked objects.
PagedResults<GraphObject> members = graphConnection.GetLinkedObjects(group, LinkProperty.Members, null, -1);

There is a convenience method to page through all the linked objects. Please use it judiciously as the links can have a lot of members.

IList<GraphObject> members = graphConnection.GetAllDirectLinks(group, LinkProperty.Members);

Adding a link

To add an object to a multi-valued link or to set the value of a single valued property, you can use the AddLink method.

graphConnection.AddLink(group, user, LinkProperty.Members);

Deleting a link

To remove an object from a multi-valued link, you can use the DeleteLink method.

graphConnection.DeleteLink(group, user, LinkProperty.Members);

To remove an object from a single-valued link, you can use the DeleteLink method.

graphConnection.DeleteLink(user, null, LinkProperty.Manager);

Property serialization

The library uses json (minimal OData metadata) for all the requests. The client library has proxy classes for all the entities that are supported for the current server version. During deserialization, when the
client library encounters additional properties (like extensions), it stores the property values in a dictionary. The JSON string that was used to deserialize is also exposed through the library.

Error handling and exceptions

When errors are encountered, an exception of type GraphException or any of its sub-types will be thrown. By default, the client will retry the requests for certain types of exceptions (Internal Server Error).
The retry behavior is fully customizable. The exception object also contains all the response headers. If you log the exception object using the ToString() method, response headers and exception details will be printed.

try
{   
     PagedResults<GraphObject> members = graphConnection.GetLinkedObjects(group, LnkProperty.Members, null);
}
catch(GraphException graphException)
{  
     Console.WriteLine(graphException.ToString());
}

Renewing expired access tokens

When the request fails due to an expired access token, the AccessTokenExpiredException will be thrown. When you handle this exception, renew the access token, update the connection.AccessToken and retry your request.

Tracing graph requests

The library traces incoming / outgoing headers along with error/warning messages. You can add any .NET TraceListener to log these messages to a persistent store.

Mocking graph client library for unit tests

All public methods on GraphConnection class are made virtual so that they can be mocked easily. GraphConnection also has a protected override that can take in mock connection manager to make sure that the calls are not actually sent to the server.

 

API Reference

Public Constructors

public GraphConnection(string accessToken)

Description

Initializes a new instance of the GraphConnection class.

Parameters

accessToken – Access token obtained for the current user/application using Active Directory Authentication Library or directly calling Microsoft Access Control Service.

Return value

NA

Exceptions

ArgumentNullException if accessToken is null.

ArgumentException if accessToken is not well formed.

Remarks

Creating a new GraphConnection does not result in a new SSL connection. The graph client library creates a new HttpWebRequest before making any request and disposes it immediately.

 

public GraphConnection(string accessToken, GraphSettings graphSettings)

Description

Initializes a new instance of the GraphConnection class, using the settings provided.

Parameters

accessToken – Access token obtained for the current user/application using Active Directory Authentication Library or directly calling Microsoft Access Control Service.

graphSettings – An instance of GraphSettings containing override properties for various properties like retry logic, api-version and graph domain name.

Exceptions

ArgumentNullException if accessToken is null.

ArgumentException if accessToken is not well formed.

 Remarks

Creating a new GraphConnection does not result in a new SSL connection. The graph client library creates a new HttpWebRequest before making any request and disposes it immediately.

 

public GraphConnection(string accessToken, Gud clientRequestId, GraphSettings graphSettings)

Description

Initializes a new instance of the GraphConnection class, using the settings provided and the client request id.

Parameters

accessToken – Access token obtained for the current user/application using Active  Directory Authentication Library or directly calling Microsoft Access Control Service.

clientRequestId – Client request identifier sent to the server along with the request that uniquely identifies the request.

graphSettings – An instance of GraphSettings containing override properties for various properties like retry logic, api-version and graph domain name.

Exceptions

ArgumentNullException if accessToken is null.

ArgumentException if accessToken is not well formed.

 Remarks

 Creating a new GraphConnection does not result in a new SSL connection. The graph client library creates a new HttpWebRequest before making any request and disposes it immediately.

 

Public Methods

public virtual TenantDetail GetTenantDetails()

Description

Gets the details of the company for the tenant associated with the accessToken.

Parameters

None

Return value

TenantDetail containing the information of the company.

Exceptions

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual PagedResults<GraphObject> List(Type objectType, string pageToken, FilterGenerator filter)

Description

Gets a page of graph objects matching the type and filter.

Parameters

objectType – Type of the requested graph objects.

pageToken – null to get the first page, PagedResults.PageToken from the previous page to the next page.

filter – null to get all the results, a valid FilterGenerator to filter on specific properties or expand specific properties.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

ArgumentNullException if objectType is null.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

UnsupportedQueryException if the filter provided is not supported by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual PagedResults<T> List<T>(string pageToken, FilterGenerator filter)

Description

Override method to list the graph objects that match the filter.

Parameters

pageToken – null to get the first page, PagedResults.PageToken from the previous page to the next page.

filter – null to get all the results, a valid FilterGenerator to filter on specific properties or expand specific properties.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

UnsupportedQueryException if the filter provided is not supported by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual T Get<T>(string objectId)

Description

Gets an object of given type identified by the unique objectId.

Parameters

objectId – Unique object identifier set by the server when the graph object was created.

Return value

The requested graph object.

Exceptions

ArgumentNullException if the given objectId is null or empty.

ObjectNotFoundException if no graph object exists with the given objecId.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual GraphObject Get(Type objectType, string objectId)

Description

Overload that is to be used when the object type is not known at the compile time.

Parameters

objectType – Type of the graph object.

objectId – Unique object identifier set by the server when the graph object is created.

Return value

The requested graph object.

Exceptions

ArgumentNullException if the given objectType or objectId is null or empty.

ObjectNotFoundException if no graph object exists with the given objecId.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual T Add<T>(T graphObject)

Description

Creates the given object in graph.

Parameters

graphObject – A graph object with required properties.

Return value

Created object returned by the server.

Exceptions

ArgumentNullException if the given graphObject is null.

ArgumentException if given graph object is not supported for creation.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

PropertyValidationException if any of the required properties are not set on graph object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual GraphObject Add(Type objectType, GraphObject graphObject)

Description

Overload for creating the graph object when the type is not known during compile time.

Parameters

objectType – Type of the graph object.

graphObject – A graph object with required properties.

Return value

Created object returned by the server.

Exceptions

ArgumentNullException if the given objectType or graphObject is null.

ArgumentException if given graph object is not supported for creation.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

PropertyValidationException if any of the required properties are not set on graph object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual T Update<T>(T graphObject)

Description

Updates the given object using the graph api.

Parameters

graphObject – A graph object with any changed properties. Only changed properties are sent to the server.

Return value

Updated object returned by the server.

Exceptions

ArgumentNullException if the given graphObject is null.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

ObjectNotFoundException if the object being updated was not found.

PropertyValidationException if there is a syntax violation with the property being updated.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual GraphObject Update(GraphObject graphObject)

Description

Updates the given object using the graph api.

Parameters

graphObject – A graph object with any changed properties. Only changed properties are sent to the server.

Return value

Updated object returned by the server.

Exceptions

ArgumentNullException if the given graphObject is null.

BadRequestException if any of the values set on the graph object are not allowed.

DuplicateObjectException if a graph object already exists with same unique identifier.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

ObjectNotFoundException if the object being updated was not found.

PropertyValidationException if there is a syntax violation with the property being updated.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual void Delete(GraphObject graphObject)

Description

Deletes the given object using the graph api.

Parameters

graphObject – A graph object with unique object identifier.

Return value

None

Exceptions

ArgumentNullException if the given graphObject is null.

ObjectNotFoundException if the graph object does not exit.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

BadRequestException if DELETE is not supported on this entity.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual PagedResults<GraphObject> GetLinkedObjects(GraphObject graphObject, LinkProperty linkProperty, string nextPageToken)

Description

Gets a page of linked objects of a graph object given the link name.

Parameters

graphObject – Graph object that contains links.

linkProperty – Link property name (Manager, Members, etc.,)

nextPageToken – null to request for first page, a valid PageToken from a previous PagedResults.PageToken to request for a next page.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

ArgumentNullException if graphObject is null.

ArgumentExecption if the given linkProperty is not supported on the given graphObject.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual PagedResults<GraphObject> GetLinkedObjects(GraphObject graphObject, LinkProperty linkProperty, string nextPageToken, int top)

Description

Overload for getting linked objects to request for specific number of results in the page specified by “top”.

Parameters

graphObject – Graph object that contains links.

linkProperty – Link property name (Manager, Members, etc.,)

nextPageToken – null to request for first page, a valid PageToken from a previous PagedResults.PageToken to request for a next page.

Top – Number of values to be returned by the server.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

ArgumentNullException if graphObject is null.

ArgumentExecption if the given linkProperty is not supported on the given graphObject.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual IList<GraphObject> GetAllDirectLinks(GraphObject graphObject, LinkProperty linkProperty)

Description

Gets all pages of linked objects of a graph object given the link name. If multiple pages exist, the call will enumerate through all the pages.

Parameters

graphObject – Graph object that contains links.

linkProperty – Link property name (Manager, Members, etc.,)

Return value

List containing all the linked objects.

Exceptions

ArgumentNullException if graphObject is null.

ArgumentExecption if the given linkProperty is not supported on the given graphObject.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual void AddLink(GraphObject sourceObject, GraphObject targetObject, LinkProperty linkProperty)

Description

Adds a link specified by the linkProperty between the source and the target graph objects

Parameters

sourceObject – Source graph object.

targetObject – Target graph object.

linkProperty – Link property name (Manager, Members, etc.,)

Return value

None.

Exceptions

ArgumentNullException if sourceObject or targetObject are null.

ArgumentExecption if the given linkProperty is not supported between source object and target object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual void DeleteLink(GraphObject sourceObject, GraphObject targetObject, LinkProperty
linkProperty)

Description

Deletes a link specified by the linkProperty between the source and the target graph objects

Parameters

sourceObject – Source graph object.

targetObject – Target graph object.

linkProperty – Link property name (Manager, Members, etc.,)

Return value

None.

Exceptions

ArgumentNullException if sourceObject or targetObject are null.

ArgumentExecption if the given linkProperty is not supported between source object and target object.

ObjectNotFoundException if the given link does not exist between source object and target object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual Stream GetStreamProperty(GraphObject graphObject, GraphProperty graphProperty, string acceptType)

Description

Gets a stream property specified by graphProperty on a given graph object.

Parameters

graphObject – Graph object on which stream property needs to be obtained.

graphProperty – Name of stream property

acceptType – Stream type to be specified for ContentType header (like image/jpeg, image/gif, etc.,)

Return value

MemoryStream representing the obtained stream.

Exceptions

ArgumentNullException if graphObject or acceptType are null.

ArgumentExecption if the given graphProperty is not supported on the graph object.

BadRequestException if the acceptType is invalid.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual void SetStreamProperty(GraphObject graphObject, GraphProperty graphProperty, MemoryStream stream, string acceptType)

Description

Sets a stream property specified by graphProperty on a given graph object.

Parameters

graphObject – Graph object on which stream property needs to be obtained.

graphProperty – Name of stream property.

stream – Stream to be set on the graph object.

acceptType – Stream type to be specified for ContentType header (like image/jpeg, image/gif, etc.,)

Return value

None

Exceptions

ArgumentNullException if graphObject or acceptType are null.

ArgumentExecption if the given graphProperty is not supported on the graph object.

BadRequestException if the acceptType is invalid.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual IList<BatchResponseItem> ExecuteBatch(params Expression<Action>[] batchRequests)

Description

Executes a list of graph methods in a single batch. All the requests are sent to the server in a single batch request and the response for each request is returned in a separate batch response item.

Parameters

batchRequests – One or more graph methods. 

Return value

List of responses, one for each of the batch request sent.

Exceptions

ArgumentExecption if the batchRequests is null or number of requests is more than 5.

BadRequestException if any of the requests is invalid.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual IList<BatchResponseItem> ExecuteBatch(IList<BatchRequestItem> batchRequests)

Description

Overload for executing batch requests if the requests are manually built using BatchRequestItem. All the requests are sent to the server in a single batch request and the response for each request is returned in a separate batch response item.

Parameters

batchRequests – One or more graph batch requests. 

Return value

List of responses, one for each of the batch request sent.

Exceptions

ArgumentExecption if the batchRequests is null or number of requests is more than 5.

BadRequestException if any of the requests is invalid.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual T GetContainment<T>(GraphObject parent, string containmentObjectId)

Description

Gets a containment object of given type identified by the unique objectId and the parent.

Parameters

parent - The parent object of the containment object.

containmentObjectId – Unique object identifier set by the server when the graph object was created.

Return value

The requested graph containment object.

Exceptions

ArgumentNullException if the given objectId is null or empty.

ObjectNotFoundException if no graph object exists with the given containmentObjectId or if the parent object does not exist.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual GraphObject GetContainment(GraphObject parent, Type objectType, string containmentObjectId)

Description

Overload that is to be used when the object type is not known at the compile time for getting a containment object.

Parameters

parent - The parent object of the containment object.

objectType – Type of the graph object.

containmentObjectId – Unique object identifier set by the server when the graph object is created.

Return value

The requested graph containment object.

Exceptions

ArgumentNullException if the given objectType or objectId is null or empty.

ObjectNotFoundException if no graph object exists with the given containmentObjectId or if the parent object does not exist.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual T AddContainment<T>(GraphObject parent, T containmentObject)

Description

Creates the given containment object in graph.

Parameters

parent - The parent object of the containment object.

containmentObject – A graph object with required properties.

Return value

Created object returned by the server.

Exceptions

ArgumentNullException if the given graphObject is null.

ArgumentException if given graph object is not supported for creation.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

PropertyValidationException if any of the required properties are not set on graph object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual GraphObject AddContainment(GraphObject parent, GraphObject containmentObject)

Description

Creates the given containment object in graph.

Parameters

parent - The parent object of the containment object.

containmentObject – A graph object with required properties..

Return value

Created object returned by the server.

Exceptions

ArgumentNullException if the given objectType or graphObject is null.

ArgumentException if given graph object is not supported for creation.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

PropertyValidationException if any of the required properties are not set on graph object.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual T UpdateContainment<T>(GraphObject parentObject, T containmentObject)

Description

Updates the given containment object using the graph api.

Parameters

parent - The parent object of the containment object.

containmentObject – A graph object with required properties..

Return value

Updated object returned by the server.

Exceptions

ArgumentNullException if the given graphObject is null.

BadRequestException if any of the values set on the graph object are invalid.

DuplicateObjectException if a graph object already exists with same unique identifier.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

ObjectNotFoundException if the object being updated was not found.

PropertyValidationException if there is a syntax violation with the property being updated.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual void DeleteContainment(GraphObject containmentObject)

Description

Deletes the given containment object using the graph api.

Parameters

parent - The parent object of the containment object.

containmentObject – A graph object with unique object identifier.

Return value

None

Exceptions

ArgumentNullException if the given graphObject is null.

ObjectNotFoundException if the graph object does not exit.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

QuotaExceededException if number of objects exceeded the limit set by the server. Please contact Microsoft support.

BadRequestException if DELETE is not supported on this entity.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual PagedResults<GraphObject> ListContainments(GraphObject parent, Type containmentType, string pageToken, FilterGenerator filter)

Description

Gets a page of graph containment objects on a given parent, matching the type and filter.

Parameters

parent - The parent object of the containment object.

containmentType – Type of the requested graph objects.

pageToken – null to get the first page, PagedResults.PageToken from the previous page to the next page.

filter – null to get all the results, a valid FilterGenerator to filter on specific properties or expand specific properties.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

ArgumentNullException if objectType is null.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

UnsupportedQueryException if the filter provided is not supported by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual PagedResults<T> ListContainments<T>(GraphObject parent, string pageToken, FilterGenerator filter)

Description

Override method to list the graph containment objects on a given parent that match the filter.

Parameters

parent - The parent object of the containment object.

pageToken – null to get the first page, PagedResults.PageToken from the previous page to the next page.

filter – null to get all the results, a valid FilterGenerator to filter on specific properties or expand specific properties.

Return value

PagedResults containing the requested page along with the pageToken to be used for getting next page, if next page is available.

Exceptions

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

PageNotAvailableException if pageToken has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

UnsupportedQueryException if the filter provided is not supported by the server.

GraphException if there were any network issues or if the service did not provide a valid response.

 

public virtual IList<string> GetMemberGroups(User user, bool securityEnabledOnly)

Description

Returns list of object identifiers of the groups that the given user is member of directly or transitively.

Parameters

user – User whose groups need to be returned.

securityEnabledOnly – Returns only security groups if set to true, otherwise returns all groups.

Return value

List of object identifiers of groups that the user is member of.

Exceptions

ArgumentNullExecption if the given user is null.

ArgumentException if object identifier of the user is not set.

ObjectNotFoundException if the given user does not exist.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual IList<string> CheckMemberGroups(GraphObject graphObject, IList<string> groupIds)

Description

Verifies if a given graph object is a member of given list of groups, returns a subset of groups it is member of.

Parameters

graphObject – Graph object whose groups need to be checked.

groupIds – List of groups identified by the unique object identifiers.

Return value

Subset of list of object identifiers of groups that the graph object is member of

Exceptions

ArgumentNullExecption if the given graph object or list of groupIds is null.

ArgumentException if object identifier of the graph object is not set.

ObjectNotFoundException if the given graph object does not exist.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual Application Restore(Application application, IList<string> identifierUris)

Description

Restores a soft deleted Application object and adds the given list of identifierUris to it.

Parameters

Application – Application that needs to be restored.

identifierUris – List of identifier URIs that need to be added to the application.

Return value

Restored application.

Exceptions

ArgumentNullExecption if the given application object is null.

ArgumentException if object identifier of the application is not set.

ObjectNotFoundException if the given application does not exist.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual User AssignLicense(User user, IList<AssignedLicense> addLicenses, IList<Guid> removeLicenses)

Description

Adds/removes the licenses on a given user.

Parameters

user – User whose licenses needs to be managed.

addLicenses – List of licenses to be assigned to the user.

removeLicenses – Lise of licenses to be removed from the user.

Return value

Updated user after adding/removing the licenses.

Exceptions

ArgumentNullExecption if the given user object is null.

ArgumentException if object identifier of the user is not set.

ObjectNotFoundException if the given user does not exist.

BadRequestException if any of the given licenses to be added or removed are invalid.

AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.

 

public virtual bool IsMemberOf(string groupId, string memberId)

Description

Verifies if a given member is a member of given group.

Parameters

groupId – Unique object identifier of the given group.

memberId – Unique object identifier of the given graph object.

Return value

True if the member is part of the group member, false otherwise.

Exceptions

ArgumentNullExecption if the given groupId or memberId is null.

ObjectNotFoundException if the given group or member does not exist.AuthenticationException if accessToken provided as a part of GraphConnection is not valid.

ExpiredTokenException if accessToken provided as a part of GraphConnection has expired.

RequestThrottledException if number of calls has exceeded the throttle limit set by the server.