Search code examples
autodesk-forgeautodesk-data-managementautodesk-bim360

Error on rename BIM360 file


I'm trying rename a file on a BIM360 account using this end point link

But every request return this message:

{
    "jsonapi":{
        "version":"1.0"
        },
    "errors":[
        {
            "id":"8b976b03-ed82-425b-819d-e0e62f931182",
            "status":"400",
            "code":"BAD_INPUT",
            "title":"One or more input values in the request were bad",
            "detail":"Request input is invalid for this operation."
        }
    ]
}

Method used:

    public async Task RenameFile(string newFileName, string projectId, string itemId)
    {
                if (string.IsNullOrEmpty(projectId) || string.IsNullOrEmpty(itemId) ||
                    string.IsNullOrEmpty(newFileName)) return;

                var body = JObject.FromObject(new {
                    jsonapi = new
                    {
                        version = "1.0"
                    },
                    data = new
                    {
                        type = "items",
                        id = itemId,
                        attributes = new
                        {
                            displayName = newFileName
                        }
                    }
                });

                var client = new RestClient(BaseUrl);

                var request = new RestRequest("/data/v1/projects/{project_id}/items/{item_id}", Method.PATCH);

                request.AddHeader("Authorization", "Bearer " + TokenBim360.AccessToken);
                request.AddUrlSegment("project_id", projectId);
                request.AddUrlSegment("item_id", itemId);
                request.AddParameter("application/vnd.api+json", body.ToString(Formatting.None), ParameterType.RequestBody);

                var response = await client.ExecuteTaskAsync(request);
    }

The most strange things is that same code works fine in A360...

What I'm doing wrong?


Solution

  • PATCH for updating names on BIM 360 only works for Folders unfortunately. File names cannot be updated from the API. You are not doing anything wrong, just the functionality is not available. I will talk to the engineering team since this request has been coming from other developers as well, to be consider to be added in a next version.