What is the API call to create external sharelink for a pdf

What is the API call to create external sharelink for a pdf

Here's my code

  1.         mp = Map();
  2. mp.put("Accept","application/vnd.api+json");
  3. // Parameters Map
  4. externalLinkMap = Map();
  5. externalLinkMap.put("resource_id",resource_id);
  6. externalLinkMap.put("link_name","link");
  7. externalLinkMap.put("request_user_data",false);
  8. externalLinkMap.put("allow_download",true);
  9. // Give view-only access
  10. externalLinkMap.put("role_id","34");
  11. attributesMap = {"attributes":externalLinkMap,"type":"links"};
  12. dataMap = Map();
  13. dataMap.put("data",attributesMap);
  14. // Create external share link
  15. external_link_data = invokeurl
  16. [
  17. url :"https://www.zohoapis.com/workdrive/api/v1/links"
  18. type :POST
  19. parameters:dataMap.toString()
  20. headers:mp
  21. connection:"workdrive_all"
  22. ];
The connection has the correct scope(s).

The error message is 
  1. {"errors":[{"id":"R008","title":"Unauthorized access"}]}
I know the code works for native Zoho document types such as a sheet.