So, in my project I send an audio file to Dropbox through Dropbox package, and it works just fine, but I want in the response also a link for the uploaded audio file and this is not provided in the initial upload response. And with some research I found out that there's a function that can create a shared Link but it's not working and it's giving 400 bad request for some reason. I really tried different things like putting the parent path before the audio file path, and using the lower version of the path and using the audio file id but it's all giving 400 bad request.
const handleSave = async () => {
setIsSaved(true);
setRecord(false);
if (audioBlob) {
const currentDate = new Date();
const fileName = `recorded_audio_${currentDate.toISOString()}.wav`;
try {
const response = await dbx.filesUpload({
path: `/${fileName}`,
contents: audioBlob,
});
console.log("File uploaded successfully!", response);
setShowDownload(false);
const uploadedFile = response.result;
const shareLink = await dbx.sharingCreateSharedLinkWithSettings({
path: uploadedFile.path_display,
requested_visibility: 'public'
});
console.log("Share link created:", shareLink.result.url);
} catch (error) {
console.error("Error uploading file to Dropbox:", error);
}
}
};
and this is response in the console:
Record.tsx:80
POST https://api.dropboxapi.com/2/sharing/create_shared_link_with_settings 400 (Bad Request)
Record.tsx:87 Error uploading file to Dropbox: DropboxResponseError: Response failed with a 400 code
at dropbox.js?v=2aef07da:1071:11
at async handleSave (Record.tsx:80:35)
