【问题标题】:AutoDesk Forge API uploading file failsAutoDesk Forge API 上传文件失败
【发布时间】:2018-10-11 01:26:00
【问题描述】:

我们正在关注tutorial for uploading a file,但似乎无法成功完成最后一步(第 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."
    }
  ]
}

非常感谢任何帮助。

【问题讨论】:

    标签: autodesk-forge autodesk autodesk-data-management


    【解决方案1】:

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

    您没有提及您是上传到 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}"
      }
    }
    

    【讨论】:

    • 谢谢西蒙!问题在于使用“type”:“items:autodesk.core:File”而不是“items:autodesk.bim360:File”。切换这些值解决了这个问题。我们为文件夹 ID 使用了正确的值,我在发布问题时只是复制/粘贴错误。
    猜你喜欢
    • 2017-01-12
    • 1970-01-01
    • 2021-08-21
    • 2019-03-24
    • 2020-07-27
    • 1970-01-01
    • 2019-12-23
    • 2017-12-07
    • 2021-09-01
    相关资源
    最近更新 更多