office365microsoft-graph-apioutlook-restapi

Move contacts or contact folders in Microsoft Graph or Outlook API


My question is if it is possible to change the ParentFolderId property of a contactFolder resource and/or a contact resource through the Microsoft Outlook API or Microsoft Graph and how. (I already know that Microsoft Graph is using under the hood Microsoft Outlook API for the Outlook features from that post Outlook REST API vs Microsoft Graph).

I have tried to do so but to no avail. So I am convinced that this functionality is not supported.


What I have done:

I already have tried to do it through a PATCH call. The PATCH call works as it should, a 200 status code is returned, I can change for example other properties but it doesn't work for the ParentFolderId, it is just ignored.

The online documentation has an example where the above should work. In the example they include in the body the ParentFolderID and they get it in the response, but due to my own tries and the fact that the example seems mocked I have come to believe that it is just an oversight. Here is the link to that example: https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/contactfolder_update

A side-note: you will not find in the Outlook API docs any info on supporting POST and PATCH operations in contact folders but the API supports them just right (see https://msdn.microsoft.com/en-us/office/office365/api/contacts-rest-operations). The Graph API docs are more complete in that aspect since they cover POST and PATCH operations for contact folders also.


So just in case the change of ParentFolderId is supported and I am not doing something right, here is an example of what I am trying. The following is for outlook.office.com API v2.0 but I have also used all the possibilities with versions v1.0, and beta and also used graph.microsoft.com with versions v1.0 and beta, changing the names of the properties accordingly (outlook.com props are in Pascal Case).

curl --request PATCH \
  --url https://outlook.office.com/api/v2.0/me/contacts/AQMkADAwATNiZmYAZC0wNTUAZi1mNjU1AC0wMAItMDAKAEYAAAM_h46UdfWbRLlZWFB3Ty59BwAxLPcv2HzQSobPUzuXLWg7AAAAAereLgAAADEs9y-YfNBKhs9TO5ctaDsAAAAB6uX5AAAA \
  --header 'authorization: Bearer EwAAA+l...59wYC' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n   "ParentFolderId": "AQMkADAwATNiZmYAZC0wNTUAZi1mNjU1AC0wMAItMDAKAC4AAAM_h46UdfWbRLlZWFB3Ty59AQAxLPcv2HzQSobPUzuXLWg7AAACAQ4AAAA=",\n "GivenName": "John"\n}'

(I have of course removed the Bearer token details)

I want that functionality in order to implement an efficient move operation of contacts and/or contact folders. The alternative of copying/deleting is not efficient and also does not keep the ids of the things "moved", since they will have to be created again.


Solution

  • You cannot change the ParentFolderId of any entity in the Outlook world by PATCH'ing. That property is managed by the server. The only way it changes is by moving the item in question. Unfortunately there is no Move action defined for contacts or contact folders in the API.