Skip to main content
Question

Error when trying to createmetadata using CreateFileMetadataAsync API

  • May 23, 2025
  • 1 reply
  • 11 views

Forum|alt.badge.img

Hello,

I am trying to create metadata for file requests and I am seeing 404 not found error. I am not sure what is missing. Below is my code.

 var boxFileRequestObjectresponse = new BoxFileRequestObject();
            var boxhelper = new BoxHelper(_configuration);
            boxhelper.CreateClient(_configuration);
            var boxFileRequestId = _configuration.GetSection("BoxFileRequestId");            try
            {

            /Get khcnumber
                var destinationFolder = new BoxRequestEntity
                {
               // Box parent folder
                    Id = "159523690847",
                    Type = BoxType.folder                    
                };
                string khc = KHCNumber.ToString();
                var copyRequest = new BoxFileRequestCopyRequest
                {
                    Description = khc,
                    Folder = destinationFolder                    
                };
                var metadataValues = new Dictionary<string, object>()
                {
                    {"khcnumber",khc }
                };               
                boxFileRequestObjectresponse = await boxhelper.client.FileRequestsManager.CopyFileRequestAsync(boxFileRequestId.Value, copyRequest);

 

//Passing the boxFileRequestObjectresponse.Id as the field since the metadata needs to be created for that file.              

Dictionary<string, object> metadata = await boxhelper.client.MetadataManager                 .CreateFileMetadataAsync(boxFileRequestObjectresponse.Id, metadataValues, "enterprise", "khcFileinfo");

            }
            catch (Exception ex)
             { throw ex; }

            return Json(new { boxSharedLinkUrlResponse = boxFileRequestObjectresponse.Url }, new JsonSerializerSettings());
        }

 

Below is the error information. BOX3_Ew5kq6ADy0LAqDljsHfIqA.png

 

Any help is appreciated.

1 reply

Forum|alt.badge.img

Hi Shankar,

Typically this happens when you have a missed match or typo between the name of the attributes in the template and the name of the attributes in your code. Sometimes the names are not what we are expecting, and they are case sensitive.

Use the API to query you metadata template to get the actual names of the attributes.

Hope this helps.

Best regards