Download a Document Generated From an SCO (deprecated)
This workflow is deprecated. We will continue to support it until November 30th, 2022. We recommend migrating to the new direct-to-S3 workflow.
This tutorial demonstrates how to download a generated SCO (Supplier Change Order) document from BIM 360 cost management. The steps here include finding the URN from the generated document, locating the storage object for the file, and downloading the file from the storage object.
Before You Begin
- Register an app.
- Acquire a 3-legged OAuth token with
data:create
data:read
anddata:write
scopes. - Verify that you have access to the relevant BIM 360 account and BIM 360 project.
- Have the project’s
projectId
- Retrieve the project container ID for your project as described in Retrieve container id.
- Make sure that you have an SCO and that a document has been generated for it.
Step 1: Find an SCO in BIM 360 Cost Management
Find the ID of the SCO from which you want to download the download by calling GET SCO. (The SCO in this example has a generated document.) In this example, assume that the container ID is 18ece8b1-204d-11e8-ad71-d73b169f902a
.
Request
curl 'https://developer.api.autodesk.com/cost/v1/containers/18ece8b1-204d-11e8-ad71-d73b169f902a/change-orders/sco?limit=100&offset=0' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0'
Response
{
"results": [{
"id": "55254a50-44d9-11e9-99d7-79aa05d3109e",
"...":"...",
}],
"pagination": {
"totalResults": 1,
"limit": 100,
"offset": 0
}
}
In this example, the SCO ID is in the first part of the response(results[0].id
). It’s 55254a50-44d9-11e9-99d7-79aa05d3109e
. You’ll use it in the next step.
Step 2: Find the Document Generated for the SCO
Use the SCO ID (55254a50-44d9-11e9-99d7-79aa05d3109e
) to call GET cost/v1/containers/{containerId}/documents to get the generated document. The associationId value is the SCO ID 55254a50-44d9-11e9-99d7-79aa05d3109e
. The associationType value is FormInstance
.
Request
curl 'https://developer.api.autodesk.com/cost/v1/containers/18ece8b1-204d-11e8-ad71-d73b169f902a/documents?associationId=55254a50-44d9-11e9-99d7-79aa05d3109e&associationType=FormInstance' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0' -H 'Content-Type: application/json'
Response
{
"id": "80b446f0-4261-11e9-9f1f-e19f7c813519",
"urn": "urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w?version=1",
"...": "..."
}
The URN urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w?version=1
is the version URN you use to access the data management service in the next step.
Step 3: Find the Storage Object ID
Use encodeURIComponent to encode the object ID urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w?version=1
as urn%3Aadsk.wipprod%3Afs.file%3Avf.kYtkYWBsSKSCMXYzEYe80w%3Fversion%3D1
. Then use the encoded ID as the version ID to call GET projects/:project_id/versions/:version_id
Request
curl 'https://developer.api.autodesk.com/data/v1/projects/b.e8d3c2a0-b913-11e9-893e-e55449557ed8/versions/urn%3Aadsk.wipprod%3Afs.file%3Avf.kYtkYWBsSKSCMXYzEYe80w%3Fversion%3D1' -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsImtpZCI6Imp3dF9zeW1tZXRyaWNfa2V5In0' -H 'Content-Type: application/json'
Response
{
"jsonapi": {
"version": "1.0"
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1"
}
},
"data": {
"type": "versions",
"id": "urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w?version=1",
"attributes": {
"name": "5075E0I9C51MbcYH.docx",
"displayName": "5075E0I9C51MbcYH",
"createTime": "2019-03-12T15:14:00.0000000Z",
"createUserId": "",
"createUserName": "",
"lastModifiedTime": "2019-03-12T15:14:00.0000000Z",
"lastModifiedUserId": "",
"lastModifiedUserName": "",
"versionNumber": 1,
"fileType": "docx",
"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"
}
}
},
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1"
}
},
"relationships": {
"item": {
"data": {
"type": "items",
"id": "urn:adsk.wipprod:dm.lineage:kYtkYWBsSKSCMXYzEYe80w"
},
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1/item"
}
}
},
"links": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1/relationships/links"
}
}
},
"refs": {
"links": {
"self": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1/relationships/refs"
},
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1/refs"
}
}
},
"downloadFormats": {
"links": {
"related": {
"href": "https://developer.api.autodesk.com/data/v1/projects/b.6b975448-835b-4625-ad1a-0e9961749de3/versions/urn:adsk.wipprod:fs.file:vf.kYtkYWBsSKSCMXYzEYe80w%3Fversion=1/downloadFormats"
}
}
},
"derivatives": {
"data": {
"type": "derivatives",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmtZdGtZV0JzU0tTQ01YWXpFWWU4MHc_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmtZdGtZV0JzU0tTQ01YWXpFWWU4MHc_dmVyc2lvbj0x/manifest?scopes=b360project.6b975448-835b-4625-ad1a-0e9961749de3,global,O2tenant.3751451"
}
}
},
"thumbnails": {
"data": {
"type": "thumbnails",
"id": "dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmtZdGtZV0JzU0tTQ01YWXpFWWU4MHc_dmVyc2lvbj0x"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/modelderivative/v2/designdata/dXJuOmFkc2sud2lwcHJvZDpmcy5maWxlOnZmLmtZdGtZV0JzU0tTQ01YWXpFWWU4MHc_dmVyc2lvbj0x/thumbnail?scopes=b360project.6b975448-835b-4625-ad1a-0e9961749de3,global,O2tenant.3751451"
}
}
},
"storage": {
"data": {
"type": "objects",
"id": "urn:adsk.objects:os.object:wip.dm.prod/af47b92e-7096-4c1f-b090-f77b1d83485f.docx"
},
"meta": {
"link": {
"href": "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/af47b92e-7096-4c1f-b090-f77b1d83485f.docx?scopes=b360project.6b975448-835b-4625-ad1a-0e9961749de3,global,O2tenant.3751451"
}
}
}
}
}
}
Find the storage object ID. The storage
section in the response contains the storage object ID. You’ll use this ID to access the storage service in the next step.
The storage object ID parses into these three sections: <urn:adsk.objects:os.object>:<bucket_key>/<object_name>
. In this example, the bucket key is wip.dm.prod
and the storage object name is af47b92e-7096-4c1f-b090-f77b1d83485f.docx
.
Step 4: Download the File
Use the bucket key (wip.dm.prod
) and the storage object name (af47b92e-7096-4c1f-b090-f77b1d83485f.docx
) to call GET buckets/:bucket_key/objects/:object_name to download the file.
Request
curl -X GET -H "Authorization: Bearer nFRJxzCD8OOUr7hzBwbr06D76zAT" "https://developer.api.autodesk.com/oss/v2/buckets/wip.dm.prod/objects/af47b92e-7096-4c1f-b090-f77b1d83485f.docx"
Congratulations! You have downloaded the generated document from BIM 360 cost management. You can use it in different ways that include printing it out or sending it to an e-signature provider for signatures.