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.