Modifying tags with javascript/jquery
回答済みAll of the tutorials for BOX content API user cUrl examples and when I contacted tech support, they sent me here.
I am trying to udpate 21000 files with tags from a database. I have everything working except for the last step - updating the files on box with the tags.
Can some one please tell me how to use javascript/jquery/ajax to perform this cURL put?
curl https://api.box.com/2.0/files/FILE_ID \ -H "Authorization: Bearer ACCESS_TOKEN" \ -d '{"tags":"[tree,dog,grass]"}' \ -X PUT
I have searched this community and found nothing. I have searched the web and found how to get a folder but cannot figure out how to modify metadata of a file. My current ajax call DOES return the file object that I'm trying to modify. I tried GET and PUT ajax types.
Thanks
-
Figured it out:
writeTags = function(tags, callback)
{
var authHeader = "Bearer " + access_token;var tagsArray = tags.split(',');
var url = "https://api.box.com/2.0/files/" + currentFile.id;$.ajax({
url: url,
type: 'PUT',
data: JSON.stringify({tags:tagsArray}),
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", authHeader);
}, success: function(data){callback(data);
},
error: function(xhr, textStatus, error){
console.log(xhr, textStatus, error);}
});
};
サインインしてコメントを残してください。
コメント
1件のコメント