AutoDesk Forge API 上传文件失败
AutoDesk Forge API uploading file fails
我们正在关注 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."
}
]
}
非常感谢任何帮助。
(由于初学者的声誉,我还不能评论,因此写为答案)
您没有提到您是要上传到 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}"
}
}
我们正在关注 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."
}
]
}
非常感谢任何帮助。
(由于初学者的声誉,我还不能评论,因此写为答案)
您没有提到您是要上传到 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}"
}
}