Autodesk Forge Datamanagement API: No "extension.type&q

本文关键字:quot type extension No Forge Datamanagement API Autodesk | 更新日期: 2023-09-27 18:01:33

我试图通过使用"POST projects/:project_id/storage"上传文件:"在OSS中创建一个可以上传数据的存储位置。"

我检索了投影和文件夹id,我想为文件"vaac_RevBlockImperial.dwg"创建一个存储位置。我创建了这个curl-call:

curl
 -X POST
 -H "Authorization: Bearer 3-legged-token-with-data:create-scope" 
 -H "Accept: application/vnd.api+json" 
 -H "Content-Type: application/vnd.api+json" 
"https://developer.api.autodesk.com/data/v1/projects/a.cGVyc30uYWw6dWUyOTNmYmU0I0QyMDE2MDUwOTMxNzU3Mjgx/storage" 
 -d "{"""data""": {"""type""": """object""", """attributes""": {"""name""": """vaac_RevBlockImperial.dwg"""}, """relationships""": { """target""": {"""data""": { """type""": """folders""", """id""": """urn:adsk.wipprod:fs.folder:co.z9LUCe1_QoKWT8VFukdc9Q""" }}}}}"

结果,我得到以下响应:

{
    "jsonapi": {
    "version": "1.0"
},
"errors": [{
    "id": "2919a501-a362-46c4-a441-03fefcacb7b2",
    "status": "400",
    "code": "BAD_INPUT",
    "title": "One or more input values in the request were bad",
    "detail": "No '"extension.type'" found in payload."
}]
}

什么是"detail": "No '"扩展。输入"在有效载荷中发现"是什么意思?

Autodesk Forge Datamanagement API: No "extension.type&q

你的有效负载包含一个无效的类型,即它应该是"type:objects"而不是"type:object"。

彼得

谢谢你的回答。这让我找到了一个在线json验证器,在那里我根据其定义验证了主体。结果,我发现身体不见了

"jsonapi": {
    "version": "1.0"
  },

,在属性部分,需要"extension":

"extension" : {
  "type": "myType",
  "version": "myVersion",
  "schema": { "href": "myReference" }
  }

这给了我下一个json主体"POST projects/:project_id/storage"调用:

{
    "jsonapi": {
        "version": "1.0"
    },
    "data": {
        "type": "object",
        "attributes": {
            "name": "myfile.jpg",
            "extension": {
                "type": "myType",
                "version": "myVersion",
                "schema": {
                    "href": "myReference"
                }
            }
        },
        "relationships": {
            "target": {
                "data": {
                    "type": "folders",
                    "id": "urn:adsk.wipprod:fs.folder:co.mgS-lb-BThaTdHnhiN_mbA"
                }
            }
        }
   }
}

这给了我另一个错误时张贴,但JSon被接受。似乎给出的例子没有更新到最新的定义。

快速更新已在此线程中提供的答案。在线文档&教程更新以反映这些答案:https://developer.autodesk.com/en/docs/data/v2/tutorials/upload-file/