cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted

Create a folder

Explorer | Level 3

I want to create a folder as soon as the user login in the app,

i tried the following function to create folder but i can see no folder is created..

I am calling this function after the login..

 
CreateFolder()
  {

    let args={
    "path": "/Homework/math",
    "autorename": false
}
  
     let headers = new Headers();
    headers.append('Authorization','Bearer'+this.accessToken);
    headers.append('Dropbox-API-Arg', JSON.stringify(args));
    headers.append('Content-Type', 'application/json');
    console.log("created folder");
    return this.http.post('https://api.dropboxapi.com/2-beta-2/files/create_folder',{headers:headers});

  }
}



 
dropboxlogin()
{
this.dropbox.login().then((success) => {
this.navCtrl.push(DropboxloginPage);
      this.dropbox.CreateFolder();
    this.showToast("folder created");
}, (err) => {
console.log(err);
});
 
}
 
4 Replies 4
Highlighted

Re: Create a folder

Dropboxer
Dropboxer
What's the response from the server? Does the call succeed or fail? If it's failing, the response will probably tell you what's wrong.

If I had to guess, it's `Bearer'+this.accessToken. You seem to be missing a space there... try 'Bearer '+this.accessToken instead.
Highlighted

Re: Create a folder

Dropboxer
Dropboxer
Oh, I also see /2-beta-2/ in your URL. I'm not sure whether that's still expected to work, but you should really switch to /2/. Again, the HTTP response would tell you if that's the problem.

Note that /create_folder has been deprecated in favor of /create_folder_v2, so I'd recommend switching to that too: https://www.dropbox.com/developers/documentation/http/documentation#files-create_folder_v2.
Highlighted

Re: Create a folder

Explorer | Level 3

I made the changes,but still I cannot find any folder created..I am getting the toast as alert created,but when I am opening the dropbox,I cannot find the new folder created...

 

 
CreateFolder()
  {

    let args={
    "path": "/invoice",
    "autorename": false
}
   //this.dropbox.filesCreateFolder(args);
     let headers = new Headers();
    headers.append('Authorization','Bearer '+this.accessToken);
    headers.append('Dropbox-API-Arg', JSON.stringify(args));
    headers.append('Content-Type', 'application/json');
    console.log("created folder");
    return this.http.post('https://api.dropboxapi.com/2/files/create_folder_v2',{headers:headers});

  }
}
 

 

 

 

Highlighted

Re: Create a folder

Dropboxer
Dropboxer

What response are you getting from the API though? You need to check the API response to see if the call succeeded or not.

 

Also, another thing I notice is that you're sending your parameters in the 'Dropbox-API-Arg' header, but /2/files/create_folder_v2 is an RPC style endpoint, so your parameters should be sent as JSON in the request body.

Polls
Do you know how to organize your files and folders?
We have created a guide on folder best practice, so you can get organized now check it out here.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Need more support?