SOLVED

REST get OneDrive sync link

Copper Contributor

Is there a way to get or construct a Sharepoint folder sync link (for OneDrive for Business) using the REST API?
I have the requirement to implement a sync button to a application in order to remove the need for users to visit the Sharepoint Online site folder to enable OneDrive sync.
I looked all over but couldn't find any information on how the sync request works

4 Replies
Could Known Folder Move be an option for this scenario?

https://docs.microsoft.com/en-us/onedrive/redirect-known-folders

Unforturnatly, no.

 

Some additional background:

We are working with client related documents and the document library has a document set for each of the clients

The requirement is for a CRM system at a non-profit organization, the issue is that they have a network of volunteers who are mostly not very computer literate. Therefore, I want to add a OneDrive sync button to avoid the need for them to interact with the SharePoint UI.

best response confirmed by Stefan Szynaka (Copper Contributor)
Solution

after hours of hunting and following breadcrumbs I got it working.

 

the follwing URL has to be called in the browser to launch the OneDrive sync dialog:

odopen://sync?
    scope=OPENFOLDER                                                    = static
    &siteId=4d19e34e-9b05-xxxx-bb52-0cad8778ea21                        = static value/config - Site GUID -_vti_bin/client.svc/ProcessQuery or https://xxxxxxxxxxxx.sharepoint.com/sites/web/_api/web
    &webId=44b26a7c-8d22-xxxx-a337-5185e2e55d8f                         = static value/config - Web GUID - _vti_bin/client.svc/ProcessQuery
    &webTitle=OneDrive Sync button test                                 = static value/config - Teamsite title
    &listId=%7B5274FD7E-97AC-xxxx-8645-FC5410F89E27%7D                  = static value/config - _vti_bin/client.svc/ProcessQuery or Value can be found in the Sharepoint folder webpage url - &List key
    &listTitle=Prototype                                                = Document library title
    &userEmail=stefan%40xxxx                                            = user email
    &listTemplateTypeId=101                                             = static value/config - /_api/Web/Lists/getByTitle('<list name>')/BaseTemplate
    &webUrl=https%3A%2F%2xxxxxxxx.sharepoint.com%2Fsites%2Fweb          = full site url
    &webLogoUrl=%2Fsites%2Fweb%2FSiteAssets%2Fspo-shared-data.png       = website logo - can be empty
    &webTemplate=68                                                     = static value/config - /_api/web/GetAvailableWebTemplates(1033)/getbyname('SITEPAGEPUBLISHING#0')";                                                        
    &isSiteAdmin=1                                                      = 1 : yes / 0: no                                            
    &folderId=cbab51b9-fa01-xxxx-b324-ad52ff28deaf                      = folder Unique ID - /_api/web/GetFolderByServerRelativeUrl('{relative folder path}')"
    &folderName=TestFolder                                              = folder name
    &folderUrl=%2Fsites%2Fweb%2FPrototype                               = relative folder path -

To get the values for the site, web & folder ID, you have to issue a call to the

_vti_bin/client.svc/ProcessQuery

endpoint. I've attached a file with the XML payload for this call

@Stefan Szynaka you saved my days. tons of thanks, works like charm

1 best response

Accepted Solutions
best response confirmed by Stefan Szynaka (Copper Contributor)
Solution

after hours of hunting and following breadcrumbs I got it working.

 

the follwing URL has to be called in the browser to launch the OneDrive sync dialog:

odopen://sync?
    scope=OPENFOLDER                                                    = static
    &siteId=4d19e34e-9b05-xxxx-bb52-0cad8778ea21                        = static value/config - Site GUID -_vti_bin/client.svc/ProcessQuery or https://xxxxxxxxxxxx.sharepoint.com/sites/web/_api/web
    &webId=44b26a7c-8d22-xxxx-a337-5185e2e55d8f                         = static value/config - Web GUID - _vti_bin/client.svc/ProcessQuery
    &webTitle=OneDrive Sync button test                                 = static value/config - Teamsite title
    &listId=%7B5274FD7E-97AC-xxxx-8645-FC5410F89E27%7D                  = static value/config - _vti_bin/client.svc/ProcessQuery or Value can be found in the Sharepoint folder webpage url - &List key
    &listTitle=Prototype                                                = Document library title
    &userEmail=stefan%40xxxx                                            = user email
    &listTemplateTypeId=101                                             = static value/config - /_api/Web/Lists/getByTitle('<list name>')/BaseTemplate
    &webUrl=https%3A%2F%2xxxxxxxx.sharepoint.com%2Fsites%2Fweb          = full site url
    &webLogoUrl=%2Fsites%2Fweb%2FSiteAssets%2Fspo-shared-data.png       = website logo - can be empty
    &webTemplate=68                                                     = static value/config - /_api/web/GetAvailableWebTemplates(1033)/getbyname('SITEPAGEPUBLISHING#0')";                                                        
    &isSiteAdmin=1                                                      = 1 : yes / 0: no                                            
    &folderId=cbab51b9-fa01-xxxx-b324-ad52ff28deaf                      = folder Unique ID - /_api/web/GetFolderByServerRelativeUrl('{relative folder path}')"
    &folderName=TestFolder                                              = folder name
    &folderUrl=%2Fsites%2Fweb%2FPrototype                               = relative folder path -

To get the values for the site, web & folder ID, you have to issue a call to the

_vti_bin/client.svc/ProcessQuery

endpoint. I've attached a file with the XML payload for this call

View solution in original post