0
votes

Is it possible to create contact folders with Outlook REST API? I've looked into the docs for Outlook Contacts API and found only references to fetching existing contact folders (even in the beta version).

Other questions seem to focus on using C# and probably some specific SDK for that. I'm using Python, so that wouldn't work for me. I haven't found, both on StackOverflow and through Google in general, any definitive answers to this question. From the lack of any mentions in the docs, I'd assume it's not possible, but just wanted to get a definitive and/or official answer on that matter, if possible. Also please let me know if I missed something during my research. Thanks!

2

2 Answers

1
votes

There is a create folder operation, although it seems specific to Mail folders and doesn't take any parameters that can specify a folder type. It's possible it may take on the same item type as the parent folder, but I'm not certain.

Otherwise there is a create method specific for Contact folders in the Graph API; see https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/contactfolder_post_childfolders.

If you want a Python specific SDK, see: https://github.com/microsoftgraph/msgraph-sdk-python. Code samples: https://github.com/search?q=python+sample+user:microsoftgraph&type=Repositories

FYI, you can use any code platform to work with the Office 365 or Graph APIs, as long as they support REST.

0
votes

After reading @Eric Legault's answer it gave me an insight to try something blindly. Even though the docs do not state it, you can create a folder by doing a POST to the contact folders endpoint with DisplayName property in the body.

So do POST https://outlook.office.com/api/<version>/me/contactfolders with {"DisplayName": "folder_name"} in the request's body and it will work, returning the usual 201 Created response code.

This worked for me in both v2.0 and beta endpoints.

As of this writing, Outlook Contacts' UI (self-entitled Outlook People) is terrible and not user-friendly at all (either that or I just suck at understanding it), so I actually don't know how to create or delete contact folders through it, but I'm glad the REST API does the job :)