Upload Attachments to RFIs
This tutorial demonstrates how to upload attachments to RFIs. The process includes locating the ID of the project that contains the RFI, identifying the virtual folder where the attachment will be stored, creating an empty storage object, generating a signed S3 URL, and uploading the attachment using that URL.
For more details about Forma Data Management, see the Data Management API.
Before You Begin
- Register an app, and select the Data Management and Forma APIs.
- Acquire a 3-legged OAuth token with
data:createdata:readanddata:writescopes. - Assume the RFI that you want to add the attachment to is
31a3f98d-34a8-4d4c-a362-3cc9de44f89c. - Verify that you have access to the relevant Forma hub, project, and folder.
Step 1: Find the Hub ID for the Forma Hub
The first few steps of the tutorial demonstrate how to find the ID of the project that contains the RFI. This involves using several Data Management endpoints to find the folder ID.
Call GET hubs to find the hub ID for the Forma hub that includes the project that contains the RFI you want to add the attachment to.
Note that the Forma hub ID corresponds to a Data Management hub ID. To convert an account ID into a hub ID you need to add a “b.” prefix. For example, an account ID of c8b0c73d-3ae9 translates to a hub ID of **b.**c8b0c73d-3ae9.
Request
Response
In this example, assume that the RFI you want to add the attachment to is in a hub called Acme Construction.
Find the hub (data.name), and note the hub ID - b.cGVyc29uYWw6cGUyOWNjZjMy.
Step 2: Find the Project ID
Use the hub ID (b.cGVyc29uYWw6cGUyOWNjZjMy) to call GET hubs/:hub_id/projects to get a list of all the projects in the hub. Find the project ID of the project that contains the RFI you want to upload the attachment to.
Note that the project ID in Forma corresponds to the project ID in the Data Management API. To convert a project ID in Forma to a project ID in the Data Management API, you need to add a “b.” prefix. For example, a project ID of a4be0c34a-4ab7 translates to a project ID of **b.**a4be0c34a-4ab7.
Request
Response
In this example, assume that Main Street School Renovation is the project that contains the RFI you want to add the attachment to.
Find the project (data.attributes.name), and note the project ID (data.id) - b.cGVyc29uYWw6d2l.
Step 3: Find the RFI Virtual Folder ID
Note that virtual folder creation is triggered as a separate asynchronous job when an RFI is created. Until this folder is successfully created, users cannot upload files into it. To confirm that the folder is ready, call GET rfis/:id </en/docs/acc/v1/reference/http/rfis-rfis-id-GET/> and check that the virtualFolderUrn field appears in the response.
Use the project ID (b.cGVyc29uYWw6d2l) and the RFI ID (31a3f98d-34a8-4d4c-a362-3cc9de44f89c to call GET rfis/:id to get the virtual folder ID for the RFI.
To find the RFI ID, call POST search:rfis.
Request
Response
Note the virtual folder ID (virtualFolderUrn) - "urn:adsk.wip:fs.folder:co.1838SAGCQ3SPn7lqOXMaJQ".
Step 4: Create a Storage Object
Use the project ID (b.cGVyc29uYWw6d2l) and the virtual folder ID (urn:adsk.wip:fs.folder:co.1838SAGCQ3SPn7lqOXMaJQ) to call POST projects/:project_id/storage to create an empty storage object for the file in the folder.
Note that you must assign a filename and file extension (such as .pdf, .jpg, .txt, etc.) to the name parameter (for example, site-plan-v2.pdf).
Request
Response
Note the object ID (data.id) - urn:adsk.objects:os.object:wip.dm.prod/2a6d61f2-49df-4d7b.jpg.
The object ID includes the following sections: <urn:adsk.objects:os.object>:<bucket key>/<object key>
Note the bucket key - wip.dm.prod and the object key - 2a6d61f2-49df-4d7b.jpg
Step 5: Generate a Signed S3 URL
Forma stores files in Amazon S3, and uploads must go through signed URLs for security. Use the bucket key and object key to generate a signed upload URL for your storage object.
Use the bucket key (wip.dm.prod) and the object key (2a6d61f2-49df-4d7b.jpg) to call GET buckets/:bucketKey/objects/:objectKey/signeds3upload to generate a signed URL for the storage object.
This endpoint supports generating multiple signed URLs, which allows you to upload multiple chunks of the same file in parallel. For more information, see GET signeds3upload.
Request
Response
Note the uploadKey and the urls response attributes.
Step 6: Upload a File to the Signed URL
To upload the file to the signed URL, use a PUT method and the urls attribute as the URI.
Note that you should not use a bearer token with this call.
Request
Note that a successful call (200) returns an empty response.
Step 7: Complete the Upload
Use the bucket key (wip.dm.prod) the object key (2a6d61f2-49df-4d7b.jpg`) and the upload key (AQICAHifrJ6-BSHUmjAat4..........QWI-fuvghN23akgePMdmykV) to call POST buckets/:bucket_key/objects/:object_key/signeds3upload to complete the upload.
This endpoint needs to be called within 24 hours from the time you began uploading the file.
Request
Response
The file has been uploaded to the storage object.
Step 8: Assign the Attachment to a Response
At this point, the file has been uploaded to the RFI’s virtual folder — but it won’t appear in the RFI interface unless it’s assigned to a specific response.
To complete the workflow, see the Upload Attachments to RFI Responses tutorial, which shows how to attach the file to a draft response.
Note that we do not currently support the workflow to assign attachments directly to the official response via the API. This will be available in a future release.
Congratulations! You’ve completed the upload and assignment process — the attachment is now part of the RFI response and visible in the RFI interface.
Imported from the Autodesk Platform Services documentation: https://aps.autodesk.com/en/docs/acc/v1/tutorials/rfis3/rfi-upload.