I want to create a folder in my dropbox,when my app links with my dropbox account…
I am able to login in my dropbox account using app,but I have also added the function to create folder ,but I am not able to create folder…
I found this from dropbox documentation and tried this…
login()-
login(){
return new Promise((resolve, reject) => {
let browser = this.iab.create(this.url, '_blank');
let listener = browser.on('loadstart').subscribe((event: any) => {
//Ignore the dropbox authorize screen
if(event.url.indexOf('oauth2/authorize') > -1){
return;
}
//Check the redirect uri
if(event.url.indexOf(this.redirectURI) > -1 ){
listener.unsubscribe();
browser.close();
let token = event.url.split('=')[1].split('&')[0];
this.accessToken = token;
resolve(event.url);
} else {
reject("Could not authenticate");
}
});
});
}
CreateFolder()
{
let args={
"path": "/Homework/math",
"autorename": false
}
let headers = new Headers();
headers.append('Authorization','Bearer'+this.accessToken);
headers.append('Content-Type', 'application/json');
console.log("created folder");
return this.http.post('https://api.dropboxapi.com/2/files/create_folder',{headers:headers});
}
I am getting console,log(“created folder”),but I am not able to create new folder
here I am calling login and createfolder function-
dropboxlogin()
{
this.dropbox.login().then((success) => {
this.navCtrl.push(DropboxloginPage);
this.dropbox.CreateFolder();
this.showToast("folder created");
}, (err) => {
console.log(err);
});
}
Please guide where I am wrong…
links-