We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
SauravGhosh14
2 years agoExplorer | Level 3
Getting a 500 error while sharing/create_shared_link_with_settings
I am trying to use Google Apps Script to create Shared links. I have been able to work most of the functinality I require, incl. running "sharing/list_shared_links". My folder is a Team folder. H...
Greg-DB
Dropbox Staff
A 500 error would indicate an issue on the server, so we'd need to look into that. I'll be happy to help with that, but I'll need some more information. Please reply with:
- the steps to reproduce the issue with /sharing/create_shared_link_with_settings, including relevant code snippet(s), but don't include any access or refresh token(s)
- several sample 'X-Dropbox-Request-Id' response header values for the failures with a 500 code
SauravGhosh14
2 years agoExplorer | Level 3
Hi Greg-DB
Here is the code I am using
function generateLink_dropbox(id = "id:9TUWwcSqLjAAAAAAAAv4LA") {
let token = "";
const service = getService_();
token = service.getAccessToken();
const payload = {
"path": id,
"settings": {
"access": "viewer",
"audience": "public"
}
}
const response = UrlFetchApp.fetch('https://api.dropboxAPI.com/2/sharing/create_shared_link_with_settings', {
'method': 'POST',
'payload': JSON.stringify(payload),
'headers': {
'Authorization': 'Bearer ' + token,
'Content-Type': 'application/json',
"Dropbox-API-Select-User": "dbmid:XXXX"
},
'muteHttpExceptions': true
});
const responseCode = parseInt(response.getResponseCode());
const responseHeaders = response.getAllHeaders();
Logger.log(responseCode);
Logger.log(responseHeaders);
Logger.log(response.getContentText());
}
Here are a few X-Dropbox-Request-Id as requested
45ea2e435c134d95896dfe501678c271
7398c989168b4f9ab573604e11dfbf13
66c98c4fe03e4c138f50bd9a9cb79854
5883119e3efb4ef6957bec9969eea2e7
78c28c5a2ffe4ae4a5682785c23496d3
My apps script code works otherwise. I can get folder/file details. That's where I got the id of the file from.
Now, if I manually create a link in the Dropbox UI for this particular file and re run this code, I obviously get a 409 error.
{"error_summary": "shared_link_already_exists/..", "error": {".tag": "shared_link_already_exists"}}
In that case, when I manually create a link from the UI, I can get "sharing/list_shared_links" to work, no issues there.
Funny thing though. Let's say I share this particular folder/file with my personal account. From my personal account, let's say I add it to my Dropbox (Join Folder). If I then run this code, "sharing/create_shared_link_with_settings" from my personal account, I can create links.
- Greg-DB2 years agoDropbox Staff
Thanks, that's helpful.
For a file in the team space, you'll need to set the "Dropbox-API-Path-Root" accordingly in order to operate on it. The Team Files Guide has information on how to use that. Please update your code to set that.
I'll also ask the team to fix up the error handling on the server to return a more useful error for this case.
About Discuss Dropbox Developer & API
Make connections with other developers
795 PostsLatest Activity: 7 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!