Skip to main content
Question

AddCollaborationAsync failing with folder not found.

  • May 22, 2025
  • 2 replies
  • 29 views

Forum|alt.badge.img

Hi 
I am trying to add collaboration to an exisitng folder on the box using .net Code.
It seems to be failing with the error "item not found". 

{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"item","message":"Invalid value 'd_31078805586'. 'item' with value 'd_31078805586' not found"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Not Found","request_id":"***number removed for privacy***559ce71261f9c1"} 

 

Here is the code i am using.

var collab = box.AddCollaborationTask("***number removed for privacy***86", BoxType.folder, "***number removed for privacy***7", BoxType.user).Result;

 public async Task AddCollaborationTask(string boxItemId,BoxType itemType ,string collaboratorId , BoxType collaboratorType ,String role = BoxCollaborationRoles.Viewer)
        {
            const string function = "AddFileorFolderCollaborationTask";
            BoxCollaboration bxcollab = null;
            try
            {
                var addCollaborationReq = new BoxCollaborationRequest()
                {
                    Item = new BoxRequestEntity()
                    {
                        Id = boxItemId,
                        Type = itemType
                    },
                    AccessibleBy = new BoxCollaborationUserRequest()
                    {
                        Type = collaboratorType,
                        Id = collaboratorId
                    },
                    Role = role,
                };

                bxcollab = await boxAdminClient.CollaborationsManager.AddCollaborationAsync(addCollaborationReq);

               
            }
            catch(Exception e)
            {
                Logger.logMsg(function, LogLevel.LOG_ERROR, "Exception thrown : [{0}]", e.Message);
            }

            return bxcollab;
        }


Surprisingly , it is working using REST api which I tested here .
https://developer.box.com/reference#add-a-collaboration 

I double checked every input parameter. They are correct. I am not sure what i am missing . 
Any help will be appreciated.

Thanks,

Saurabh

2 replies

Forum|alt.badge.img

i am facing same issue with other APIs as well for adding tasks or comments to file.

//for adding tasks
var req = new BoxTaskCreateRequest()
                {
                    DueAt =  Convert.ToDateTime(dueDate),
                    Message = message,
                    Item = new BoxRequestEntity()
                    {
                        Id = fileId,
                        Type = BoxType.file
                    }
                };

                bxtask = await boxAdminClient.TasksManager.CreateTaskAsync(req);

//for adding comment
var req = new BoxCommentRequest()
                {
                    Message = message,
                    Item = new BoxRequestEntity()
                    {
                        Id = itemId,
                        Type = BoxType.file
                    }
                };

                bxcomment = await boxAdminClient.CommentsManager.AddCommentAsync(req);

Can anyone please help solve this ?


Forum|alt.badge.img

solved. I was using the wrong boxClient object.