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.

    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      • Sticky Posts

      • Ask the Experts: Five-hour live Q&A session with Zoho WorkDrive product experts

        Hello all, We are excited to host the Ask the Experts session on July 18, 2024 between 2:00 PM – 7:00 PM IST. Whether you're just starting to use Zoho WorkDrive, or if you've been with us for a while, this session is an amazing opportunity to discuss
      • 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.
      • 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

      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方