Copy box folder using the API in Google Apps Script
Hi guys,
I'm trying to copy a folder into another using the API and Google Apps Script. Below is what I have so far, and I know the login token is working fine because it can read my folders, just not create one. Currently I'm getting the following error:
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"missing_parameter","name":"new_parent_folder","message":"'new_parent_folder' is required"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Bad Request","request_id":"bsmt0mg760fgyoas"}
Any thoughts?
function CopyBoxFolder(){
var data = {
'name': 'MyCopiedFolder',
'id': "87711792291",
};
var options = {muteHttpExceptions: true, 'method' : 'post',
'contentType': 'application/json',
'payload' : JSON.stringify(data),
headers: {"Authorization" : "Bearer 0000000000000MYTOKEN00000000"}
}
var boxurl = "https://api.box.com/2.0/folders/87710499131/copy";
var response = UrlFetchApp.fetch(boxurl, options);
Logger.log(response.getContentText());
}
-
The error I'm seeing on the backend for this 400 is:
Invalid input: Array ( [new_parent_folder] => Array ( [object_not_found] => Array ( [folder_id] => ) [required] => 1 ) )
It seems like there's something wrong with the structure of your data variable since it's not receiving the new parent ID where you'd like the folder moved correctly when converted to JSON.
Please sign in to leave a comment.
Comments
1 comment