1

我正在尝试使用“POST projects/:project_id/storage”上传文件:“在 OSS 中创建一个可以上传数据的存储位置。”

我检索了要为文件“vaac_RevBlockImperial.dwg”创建存储位置的 projectId 和 folderId。我创建了这个 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 \"extension.type\" found in payload." 是什么意思?意思是?

4

3 回答 3

2

您的有效负载包含无效类型,即它应该是“type:objects”而不是“type:object”。

彼得

于 2016-08-10T13:40:27.937 回答
0

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

于 2016-08-23T15:23:00.713 回答
0

谢谢您的回答。这让我找到了一个在线JSON 验证器,在那里我根据其定义验证了正文。结果发现尸体不见了

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

在属性部分中,需要“扩展”:

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

这给了我下一个用于“POST projects/:project_id/storage”调用的 JSon-body:

{
    "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 被接受了。似乎给定的示例未更新为最新定义。

于 2016-08-11T10:09:59.077 回答