1

I would like to change a file directory in Autodesk BIM360 Docs without new upload. Is it possible? How could it be done?

This is an example of what I would like to achieve:

1) Upload file to a temp directory in Autodesk BIM360 Docs

2) Check file content

3) If content OK - move the file to the right directory <- How to do this without a new update?

Thanks

2 Answers2

1

You can use PATCH Items endpoint: /data/v1/projects/:project_id/items/:item_id and the following body:

{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "items",
        "id": "CURRENT_ITEM_ID",
        "relationships": {
            "parent": {
                "data": {
                    "type": "folders",
                    "id": "DESTINATION_FOLDER_ID"
                }
            }
        }
    }
}
Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
  • Would it be also possible to move the new file to a new order as an new version of a file? Lets say: Order1/file.rvt (V1) move to Order2/file.rvt (V5) – Martin Loucka Jul 21 '18 at 21:30
  • This doesn't work for BIM 360 Team unfortunately. Response from the server is that "attributes" to modify are required, then if for instance we add the attributes' displayName to put something, the message is that request must not include "relationships" – M.V. Sep 11 '18 at 08:16
0

In case someone else has the same issue, the C# API client doesn't allow to pass an object with relationships in it.

I had to extract the code needed to perform a manual REST call:

    public static async Task<bool> MoveItemToFolderAsync(
      this IItemsApi api, string projectId, string itemId, string folderId
    ) {
      dynamic postBody = new {
        jsonapi = new { version = "1.0" },
        data = new {
          type = "items",
          id = itemId,
          relationships = new {
            parent = new {
              data = new {
                type = "folders",
                id = folderId
              }
            }
          }
        }
      };
      string jsonBody = JsonConvert.SerializeObject(postBody);

      var request = new RestRequest(
        $"/data/v1/projects/{projectId}/items/{itemId}", Method.Patch);
      request.AddBody(jsonBody, "application/vnd.api+json");
      request.AddHeader (
        "Authorization", $"Bearer {api.Configuration.AccessToken}");
      request.AddHeader ("Content-Type", "application/vnd.api+json");
      var client = api.Configuration.ApiClient.RestClient;
      var response = await client.ExecuteAsync(request);
      int statusCode = (int)response.StatusCode;
      return statusCode == 200;
    }
sanzoghenzo
  • 598
  • 5
  • 21