versions API endpoint提到可以用来制作文档的副本。看来copyFrom参数是源文件urn的http编码值。示例中的Relationships.item.data.type.itemsid的值是什么?我是否需要首先创建一个空文件对象,然后在请求正文中提供该ID?
答案 0 :(得分:0)
项目ID是您要从中复制文件的Data Management API的ID。您可以通过以下方式获取它:
您不必创建一个空文件对象,只需调用API:https://forge.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-versions-POST/
例如,
这是一个存储在文档中的RVT模型,其项目数据如下:
{
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA", //!<<< Item id
"attributes": {
"displayName": "rac_basic_sample_project.rvt",
"createTime": "2019-09-25T06:56:26.0000000Z",
//...
"lastModifiedTime": "2019-09-25T06:56:27.0000000Z",
//...
"hidden": false,
"reserved": false,
"extension": {
"type": "items:autodesk.bim360:File",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/items:autodesk.bim360:File-1.0"
},
"data": {
"sourceFileName": "rac_basic_sample_project.rvt"
}
}
},
//...
}
然后调用https://developer.api.autodesk.com/data/v1/projects/ {PROJECT_ID} /items/urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA/versions以获取其版本记录:
{
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1", //!<<< Version id
"attributes": {
"name": "rac_basic_sample_project.rvt",
"displayName": "rac_basic_sample_project.rvt",
"createTime": "2019-09-25T06:56:26.0000000Z",
//...
"lastModifiedTime": "2019-09-25T06:57:54.0000000Z",
//...
"versionNumber": 1,
"storageSize": 17813504,
"fileType": "rvt",
"extension": {
"type": "versions:autodesk.bim360:File",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:File-1.0"
},
"data": {
"processState": "PROCESSING_COMPLETE",
"extractionState": "SUCCESS",
"splittingState": "NOT_SPLIT",
"reviewState": "NOT_IN_REVIEW",
"revisionDisplayLabel": "1",
"sourceFileName": "rac_basic_sample_project.rvt"
}
}
},
//...
}
现在,您要将此项的特定版本urn:adsk.wipprod:fs.file:vf.rH_L4XJsTmeiYA4ixCVNAA?version=1
复制到另一个文件夹urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ
。因此,API调用将如下所示:
注意。版本ID的网址安全格式为urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1
POST https://developer.api.autodesk.com/data/v1/projects/{PROJECT_ID}/items?copyFrom=urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:rH_L4XJsTmeiYA4ixCVNAA",
"relationships": {
"tip":{
"data":{
"type":"versions",
"id":"1"
}
},
"parent": {
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ" //!<<< The folder we want to put this file
}
}
}
},
"included":[
{
"type":"versions",
"id":"1",
"attributes":{
"name":"rac_basic_sample_project.rvt" //!<<< Version name
}
}
]
}
希望有帮助!