We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
emarco
6 years agoExplorer | Level 3
Problem with paths using create_shared_link_with_settings
Hey,
I'm trying to make a php code that will automatically create a shared link for the files I'm uploading and add it to an XML file.
Both the upload and XML file are updating correctly, but I'm stuck with the generation of the link. This is the part of code that i'm running right now:
$parameters = array('path' => $filename); $headers = array('Authorization: Bearer token','Content-Type: application/json'); $curlOptions = array( CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($parameters), CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true ); $ch = curl_init('https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings'); curl_setopt_array($ch, $curlOptions); $linkdropbox = curl_exec($ch); curl_close($ch); $nodeDescargaText = $xml -> createTextNode($linkdropbox);
Filename is
$filename = "/".$_FILES['inputFile']['name'];
So, I keep getting errors like:
"The root path is unsupported"
"Malformed path"
I have tried leaving the root both with "" or with "/", and also have tried putting in the root the name of the Apps folder, (Apps, Aplicaciones, manualesint), the last one being the folder to where are the files being uploaded. None seems to make this work. I have tried all of them both with a "/" after, before, both, or without.
On the upload code, I'm uploading the file using "/"+name of the file, and it's working like a charm.
Any help will be appreciated!
[Cross-linking for reference: https://stackoverflow.com/questions/53499573/problem-with-paths-using-create-shared-link-with-settings ]
Getting a shared link for the root is not supported, so supplying a path like "" or "/" is expected to fail like that.
To get the shared link for a file, you should supply the full path to the file, including the file name and extension. For example, for a file "example.xml" in a folder "Documents", the path would be: "/Documents/example.xml".
You can construct these paths manually if you want, but it's better to use the paths returned by the API itself. For instance, when uploading a file, the API returns the metadata for the uploaded file in the response body. Specifically, you should use the returned 'path_lower' value.
- Greg-DBDropbox Staff
[Cross-linking for reference: https://stackoverflow.com/questions/53499573/problem-with-paths-using-create-shared-link-with-settings ]
Getting a shared link for the root is not supported, so supplying a path like "" or "/" is expected to fail like that.
To get the shared link for a file, you should supply the full path to the file, including the file name and extension. For example, for a file "example.xml" in a folder "Documents", the path would be: "/Documents/example.xml".
You can construct these paths manually if you want, but it's better to use the paths returned by the API itself. For instance, when uploading a file, the API returns the metadata for the uploaded file in the response body. Specifically, you should use the returned 'path_lower' value.
- emarcoExplorer | Level 3
Hey Greg,
Thanks for the input, will give it a try and get back with the results!
- emarcoExplorer | Level 3
Okay, so after testing what you told me, I managed to make it "work".
The problem I am having now, is that I append the result into a text node, and when clicking that, I get redirected to something like:
Whilst, obviously, I just want the download link which is in the first line, in this case it being:
https:/www.dropbox.com/s/3qy4rbv5n5nlabcm/example.xml
Have deleted the file since it was an example, but the link was working previously.
Any idea how to just get the link back?
Really appreciating your help Greg
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 4 hours 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!