0

我们正在按照上传文件的教程进行操作,但似乎无法成功完成最后一步(步骤 5:创建上传文件的第一个版本)。我们能够成功解析目标项目和文件夹,创建存储位置,并将文件上传到存储位置。

然后,我们尝试调用端点以在文件夹中创建文件的版本。

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}"
          }
        }
      }
    }
  ]
}

响应始终为 400(错误请求),并包含以下详细信息:

{
  "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."
    }
  ]
}

任何帮助是极大的赞赏。

4

1 回答 1

0

(由于初学者的声誉,我还不能发表评论,因此写作为答案)

您没有提及您是上传到 BIM 360 Team 还是 BIM 360 Document Management 项目,所以我将假设BIM 360 Team,因为这就是本教程的基础。

注意:要上传到 BIM 360 Document Management,*:autodesk.bim360:File必须使用类型(而不是*:autodesk.core:File.

关于您的请求负载,您需要提供文件夹 URN,而不是项目 ID:

"parent": {
  "data": {
    "type": "folders",
    "id": "{folderURN}"
  }
}
于 2018-05-01T09:16:54.680 回答