Modifying tags with javascript/jquery

Go to solution
Occasional Contributor

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 \
-H "Authorization: Bearer ACCESS_TOKEN" \
-d '{"tags":"[tree,dog,grass]"}' \

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.



Occasional Contributor

Re: Modifying tags with javascript/jquery

Figured it out:


writeTags = function(tags, callback)
     var authHeader = "Bearer " + access_token;

     var tagsArray = tags.split(',');
     var url = "" +;

          url: url,
          type: 'PUT',
          data: JSON.stringify({tags:tagsArray}),
          beforeSend: function(xhr) {
               xhr.setRequestHeader("Authorization", authHeader);
         }, success: function(data){

         error: function(xhr, textStatus, error){
              console.log(xhr, textStatus, error);}