Reputation: 21
I am trying to upload a file by using the "POST projects/:project_id/storage": "Creates a storage location in the OSS where data can be uploaded to."
I retrieved the projectId and folderId where I want to create a storage location for the file "vaac_RevBlockImperial.dwg". I created this 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""" }}}}}"
As a result, I get following response:
{
"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."
}]
}
What does "detail": "No \"extension.type\" found in payload." mean?
Upvotes: 1
Views: 225
Reputation: 1
Quick update following the answers already provided in this thread. The online documentation & tutorial were updated to reflect those answers: https://developer.autodesk.com/en/docs/data/v2/tutorials/upload-file/
Upvotes: 0
Reputation: 21
Thank you for your answer. That led me to an online JSON-validator where I validated the body against its definition. As a result, I found that the body was missing
"jsonapi": {
"version": "1.0"
},
and in the attributes-part, "extension" was required:
"extension" : {
"type": "myType",
"version": "myVersion",
"schema": { "href": "myReference" }
}
This gave me the next JSon-body for a "POST projects/:project_id/storage"-call:
{
"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"
}
}
}
}
}
Which gave me another error when posting, but the JSon was accepted. It seems the given example(s) weren't updated to the latest definition.
Upvotes: 0
Reputation: 21
Your payload contains an invalid type, i.e. it should be "type:objects" instead of "type:object".
Peter
Upvotes: 2