Zoho WorkDrive API - Share Files/Folders to Group Members

Zoho WorkDrive API - Share Files/Folders to Group Members

I have been able to make successful use of the Zoho WorkDrive API with the List Files/Folders inside a Folder API or request which can be referenced here https://help.zoho.com/portal/en/community/topic/zoho-workdrive-api-problem. However, I am having issues with the Share Files/Folders to Group Members API or request.
The code that I am using is as follows:
  1.  <?php

    //the parameters or request body parameters
    $postFields = array(
        'resource_id' => '31nvpbc7a8956244b406d9b2fab919c1ed8b1',
        'shared_type' => 'everyone',
        'role_id' => '34'
                       );


    $curl_var = curl_init();
    curl_setopt($curl_var, CURLOPT_URL, $curl_url);
    curl_setopt($curl_var, CURLOPT_POST, 1);
    curl_setopt($curl_var, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl_var, CURLOPT_POSTFIELDS, $postFields);
    curl_setopt($curl_var, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_var, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token, 'cache-control: no-cache'));

    $response = curl_exec($curl_var);

    $err = curl_error($curl_var);
    if ($err) {
        echo "cURL Error #:" . $err;
    } else{
        echo '<pre>';
        print_r($response);
    }

    ?>

The error I receive says the following:
{"errors":[{"id":"F6012","title":"Number of parameters is more than specified"}]}

==========> PART 2 <==========

I consulted this issue with a software engineer friend and he explained based on the documentation listed here https://workdrive.zoho.com/apidocs/v1/filefoldersharing/shareeveryone that the format for the Request payload in the Share WorkDrive API is incorrect and I corrected it and the following is the code that I utilized:

  1.  <?php
    //the parameters or request body parameters
    $postFields = array(
                            'data' => array(
                                'attributes' => array(
                                    'resource_id' => "31nvpbc7a8956244b406d9b2fab919c1ed8b1",
                                    'shared_type' =>  "everyone",
                                    'role_id' => "6"
                                    ),
                                'type' => "permissions"  
                            )
                       );
    $data_to_post = json_encode($postFields);
    $curl_variable = curl_init();
    curl_setopt($curl_variable, CURLOPT_URL, $curl_url);
    curl_setopt($curl_variable, CURLOPT_POST, 1);
    curl_setopt($curl_variable, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_variable, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl_variable, CURLOPT_POSTFIELDS, $data_to_post);
        //curl_setopt($curl_variable, CURLOPT_POSTFIELDS,  $data_to_post); =====> {"errors":[{"id":"F7007","title":"Invalid OAuth scope."}]}                  
        //curl_setopt($curl_variable, CURLOPT_POSTFIELDS,  $postFields); =====> {"errors":[{"id":"F6012","title":"Number of parameters is more than specified"}]}
        //curl_setopt($curl_variable, CURLOPT_POSTFIELDS,  $postFields); =====> Warning: Array to string conversion in D:\xampp\htdocs\bluedot\zoho-work-drive-share-file.php on line 91
        // curl_setopt($curl_variable, CURLOPT_POSTFIELDS, http_build_query($postFields)); =====> {"errors":[{"id":"F000","title":"JSON_PARSE_ERROR"}]}                        
    curl_setopt($curl_variable, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token, 'cache-control: no-cache'));

    $response = curl_exec($curl_variable);

    $err = curl_error($curl_variable);
    if ($err) {
        echo "cURL Error #:" . $err;
    } else{
        echo '<pre>';
        print_r($response);
    }

    ?>

However, I get the following error:
{"errord":[{"id":"F7007","title":"Invalid OAuth scope."}]}

When I went through the process from the beginning I used a scope of WorkDrive.files.ALL.

This can be observed in the following snippet:

$post = [
    'code' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'client_id' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',  
    'client_secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'redirect_uri' => 'http://localhost/bluesky/',
    'grant_type' => 'authorization_code',
    'scope' => 'WorkDrive.files.ALL'
];



The question is whether or not the scope of WorkDrive.files.ALL includes or covers the scope of WorkDrive.files.sharing.CREATE. Is that the case?


Any help would be greatly appreciated.

    • Sticky Posts

    • WorkDrive API Documentation

      WorkDrive provides users and developers an extensive set of APIs to help integrate functionalities of Zoho WorkDrive with other Zoho applications and third-party tools. We have published the official WorkDrive API Documentation page for all external users.
    • Support for Search in WorkDrive TrueSync

      Zoho WorkDrive now supports searching files and folders from within the TrueSync app in your computer. From the TrueSync tray icon menu, you can search for files and folders and double-click them to open or go to the folder location. Note: If the file
    • March 15, 2023: Zoho Docs is discontinued

      As of today (March 15, 2023) Zoho Docs is discontinued for all users. We would like to thank our customers for trusting us for so many years! Going forward, we're confident you'll enjoy using Zoho WorkDrive for all your advanced file management and collaboration
    • Support for auto-upgrade in TrueSync (for Windows)

      WorkDrive TrueSync app now supports auto-upgrading to the latest version for Windows OS. You must manually download and install the TrueSync app version 3.4.0 to avail this feature. Download the latest TrueSync app for Windows (version 3.4.0) Supported
    • Introducing Collections

      Create collection links to easily request any number of users to upload files to a particular folder. Once users upload their files, you will be able to view their submissions and manage their files effortlessly. Users don't need a WorkDrive account to