0
votes

We are following the tutorial for uploading a file, but can't seem to get the last step to complete successfully (Step 5: Create the first version of the uploaded file). We are able to successfully resolve the target project and folder, create a storage location, and upload the file the storage location.

We then attempt to call the endpoint to create a version of the file in the folder.

POST  https://developer.api.autodesk.com/data/v1/projects/{the project id}/items
{
  "jsonapi": {
    "version": "1.0"
  },
  "data": {
    "type": "items",
    "attributes": {
      "displayName": "Sample.jpg",
      "extension": {
        "type": "items:autodesk.core:File",
        "version": "1.0"
      }
    },
    "relationships": {
      "tip": {
        "data": {
          "type": "versions",
          "id": "1"
        }
      },
      "parent": {
        "data": {
          "type": "folders",
          "id": "{the project id}"
        }
      }
    }
  },
  "included": [
    {
      "type": "versions",
      "id": "1",
      "attributes": {
        "name": "Sample.jpg",
        "extension": {
          "type": "versions:autodesk.core:File",
          "version": "1.0"
        }
      },
      "relationships": {
        "storage": {
          "data": {
            "type": "objects",
            "id": "{object id return from file upload}"
          }
        }
      }
    }
  ]
}

The response is always 400 (bad request) with the following details:

{
  "jsonapi": {
   "version": "1.0"
  },
  "errors": [
    {
        "id": "ed1ae266-ebe5-4414-999a-8b6302317639",
        "status": "400",
        "code": "BAD_INPUT",
        "title": "One or more input values in the request were bad",
        "detail": "Request input is invalid for this operation."
    }
  ]
}

Any help is greatly appreciated.

1

1 Answers

0
votes

(I cannot comment yet due to beginners reputation, thus writing as answer)

You don't mention whether you are uploading to a BIM 360 Team or BIM 360 Document Management project, so I'm going to assume BIM 360 Team, as that's what the tutorial is based on.

Note: To upload to BIM 360 Document Management, type *:autodesk.bim360:File must be used (instead of *:autodesk.core:File.

Regarding your request payload, you need to provide the folder URN, not the project id:

"parent": {
  "data": {
    "type": "folders",
    "id": "{folderURN}"
  }
}