Create and Update Folders using Microsoft Graph API in Java

Microsoft provides Graph API to interact and work with Office 365 and Microsoft Cloud services. It allows you to create and manage folders, access messages, manage categories and use other services programmatically. In this article, you will learn how to use Microsoft Graph API to create and update folders in Java.

Java Microsoft Graph API to Create and Update Folders

To create and update folders using Microsoft Graph API, we will use Aspose.Email for Java. The API makes it quite easier to seamlessly work with Office 365 services using Microsoft Graph API. You can either download the API or install it using the following Maven configurations.

Repository:

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>

Dependency:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-email</artifactId>
    <version>22.3</version>
    <classifier>jdk16</classifier>
</dependency>

Create a Folder with Microsoft Graph API in Java

To communicate with the Graph API, you need to first implement the ITokenProvider interface for authenticating the requests. The following is the basic implementation of ITokenProvider.

The following are the steps to create a folder using Microsoft Graph API in Java.

The following code sample shows how to create a folder using Microsoft Graph API in Java.

Create a Subfolder using Microsoft Graph API in Java

You can also create a subfolder in a similar way. The only difference is that you have to provide the root folder’s path as the first argument of the createFolder method. The following code sample shows how to create a subfolder using Microsoft Graph API in Java.

Java: Update Folders using Microsoft Graph API

You can also fetch and update an existing folder using Microsoft Graph API. For this, you have to get the list of folders and filter the required one. The following are the steps to update a folder using Aspose.Email for Java.

The following code sample shows how to update a folder using Microsoft Graph API in Java.

Java Microsoft Graph API to Manage Folders - Get a Free License

You can get a free temporary license to create and update folders with Microsoft Graph API without evaluation limitations.

Conclusion

In this article, you have learned how to work with folders using Microsoft Graph API from within Java applications. Particularly, you have seen how to create or update a folder/subfolder with Microsoft Graph API in Java. Besides, you can explore other features of Aspose.Email for Java using the documentation. Also, in case you would have any questions, you can post to our forum.

See Also