Update Box folder using Box API C#



In this article, we will see how to update folder in Box. To update any folder we should have target folder id and folder name. 

Also as usually we need box client Id, client secret, access token and refresh token.

Here is the code which we update folder.

public async Task<BoxFolderResult> UpdateFolderUsingBOXAPI(string folderid, string foldername, BoxClientSettings BoxClientSettings, string parent_folderId = "")
        {
            BoxFolderResult objBoxFolderResult = new BoxFolderResult();
            try
            {
                BoxFolder boxFolders = new BoxFolder();
                var config = new BoxConfig(BoxClientSettings.boxClientId, BoxClientSettings.boxClientSecret, new Uri(BoxClientSettings.boxRedirectUrl));
                var session = new OAuthSession(BoxClientSettings.boxAccessToken, BoxClientSettings.boxRefreshToken, 3600, "bearer");
                var client = new BoxClient(config, session);
                BoxFolderRequest req = new BoxFolderRequest()
                {
                    Id = folderid,
                    Name = foldername
                };
                if (!string.IsNullOrEmpty(parent_folderId) && !string.IsNullOrWhiteSpace(parent_folderId))
                    req.Parent.Id = parent_folderId;
                boxFolders = await client.FoldersManager.UpdateInformationAsync(req);
                objBoxFolderResult.boxFolderObject = boxFolders;
                objBoxFolderResult.boxStatusMessage = BOXSTATUSCODES.SUCCESS.ToString();
            }
            catch (Exception ex)
            {
                objBoxFolderResult.boxStatusMessage = ex.Message;
            }
            return objBoxFolderResult;
        }

 

Labels: Update Box folder using Box API C#, BOX API C#, update folder in box, update folder using box api, update file using box api c#



Subscribe

Receive Quality Tutorials Straight in your Inbox by submitting your Email below:

Delivered by FeedBurner

Protected by Copyscape Duplicate Content Checker