Task 3 - Create a Variant
Key learnings
By the end of this task, you will be able to:
- Create a Variant
- Retrieve the created Variant
The operations used in this task are as follows:
| Operation | HTTP Request | Description |
|---|---|---|
| Create a Variant | POST /variants | Creates a Variant. |
| Get a Single Variant | GET /variants/{variantId} | Returns the details of a single variant. |
Step 1: Create a Variant
A Variant is a custom configuration of a Product Release. It contains user-defined parameters that are constrained by the rules specified in the Release. These parameters are used to generate drawing outputs for the Variant.
To create a Variant, you must specify the Release ID of the Release you created in Task 2 - Create a Release.
You also need to provide a name for the Variant and define its parameters (inputs). The inputs are an array of objects, where each object includes a name (the parameter name) and a value (the parameter value).
Request
curl -X POST \
'https://developer.api.autodesk.com/industrialized-construction/informed-design/v1/variants?accessType=<ACCESS_TYPE>&accessId=<PROJECT_ID>|<FOLDER_URN>' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"releaseId": "fd1dc14a-e3db-413e-8445-61d2a319267d",
"name": "Wall - 150x100",
"inputs": [
{
"name": "Width",
"value": 100
},
{
"name": "Height",
"value": 150
}
]
}'
Response
Returns a JSON response with status 201
{
"accessType": "{{ACCESS_TYPE}}",
"accessId": "{{ACCESS_ID}}",
"productId": "{{PRODUCT_ID}}",
"releaseId": "{{RELEASE_ID}}",
"id": "{{VARIANT_ID}}",
"name": "Rectangle Wall",
"inputs": [
{
"name": "Height",
"type": "numeric",
"unit": "in",
"label": "Height",
"value": 150,
"isInput": true
},
{
"name": "Width",
"type": "numeric",
"unit": "in",
"label": "Width",
"value": 100,
"isInput": true,
},
...
],
"createdAt": "2024-12-01T07:12:27.907Z",
"updatedAt": "2024-12-01T07:12:27.907Z"
}
Step 2: Retrieve the Variant
Using the Variant ID in the response, you can retrieve the Variant.
Request
curl -L -X GET \
'https://developer.api.autodesk.com/industrialized-construction/informed-design/v1/variants/6d28004a-b2d1-4f14-86fe-4730bf2e2703?accessType=<ACCESS_TYPE>&accessId=<PROJECT_ID>|<FOLDER_URN>' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>'
Response
Returns a JSON response with status 200 if found
{
"accessType": "ACC",
"accessId": "{{ACCESS_ID}}",
"productId": "{{PRODUCT_ID}}",
"releaseId": "{{RELEASE_ID}}",
"id": "{{VARIANT_ID}}",
"name": "Rectangle Wall",
"inputs": [
{
"name": "Height",
"type": "numeric",
"unit": "in",
"label": "Height",
"value": 150,
"visible": true,
"applicable": true
},
{
"name": "Width",
"type": "numeric",
"unit": "in",
"label": "Width",
"value": 100,
"visible": true,
"applicable": true
},
...
],
"createdAt": "2024-12-01T07:12:27.907Z",
"updatedAt": "2024-12-01T07:12:27.907Z"
}