Task 4 – Publish an Activity
An Activity is an action that can be executed in Design Automation. You create and post Activities to run specific AppBundles.
By the end of this task, you will know:
- What an Activity is.
- How to create an Activity.
- How to create new versions of an Activity.
- How to reference a specific version of an Activity by an alias.
You will use the following operations to handle Activities for this task:
HTTP Request | Description |
---|---|
POST /activities | Creates a new Activity. |
POST /activities/{id}/aliases | Creates a new alias for this Activity. |
POST /activities/{id}/versions | Creates a new version of the Activity. |
PATCH /activities/{id}/aliases/{aliasId} | Modifies alias details. |
Step 1 - Create a new Activity
To create a new Activity named ConfigureDesignActivity, post this request:
Request
curl -X POST \
'https://developer.api.autodesk.com/da/us-east/v3/activities' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-d '{
"id": "ConfigureDesignActivity",
"engine": "Autodesk.Fusion+Latest",
"commandline": [],
"parameters": {
"TaskParameters": {
"verb": "read",
"description": "the parameters for the script",
"required": false
},
"PersonalAccessToken": {
"verb": "read",
"description": "the personal access token to use",
"required": true
}
},
"appbundles": [
"YOUR_NICKNAME.ConfigureDesignAppBundle+my_working_version"
],
"settings": {},
"description": ""
}'
Attribute | Description |
---|---|
id |
The name given to your new Activity. |
engine |
The engine on which your Activity runs. The available engine versions are described in the Additional notes section in Task 3
|
appbundles |
The fully qualified id of the AppBundle referred to in commandLine . |
Response
{
"id": "<YOUR_NICKNAME>.ConfigureDesignActivity",
"engine": "Autodesk.Fusion+Latest",
"appbundles": [
"<YOUR_NICKNAME>.ConfigureDesignAppBundle+my_working_version"
],
"settings": {},
"description": "",
"version": 1
}
The response includes:
Attribute | Description |
---|---|
version |
The version number for the Activity created by the post request. A post request that creates a new Activity will get version number 1 . |
Step 2 - Create an alias to the Activity
Design Automation does not let you reference an Activity by its id
. You must always reference an Activity by an alias. Note that an alias points to a specific version of an Activity and not the Activity itself.
To create an alias named current_version
, which refers to version 1
of the ConfigureDesignActivity
:
Request
curl -X POST \
'https://developer.api.autodesk.com/da/us-east/v3/activities/ConfigureDesignActivity/aliases' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-d '{
"version": 1,
"id": "my_current_version""
}'
Response
{
"version": 1,
"id": "my_current_version"
}
Step 3 - Update an existing Activity
NOTE: This step is optional
Design Automation does not let you overwrite an Activity once you have created it. If you want to modify/update an existing Activity,
you must update it as a new version.
If you try to overwrite an existing Activity, Design Automation returns a `409 Conflict
error.
To create a new version of an Activity:
Request
curl -X POST \
'https://developer.api.autodesk.com/da/us-east/v3/activities/ConfigureDesignActivity/versions' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"id": null,
"engine": "Autodesk.Fusion+Latest",
"appbundles": [
"<YOUR_NICKNAME>.ConfigureDesignActivity+my_working_version"
],
"settings": {},
"description": ""
}'
Note: You can omit id
from the request body. If you include id
in the request body, set it to null
. If you don’t set it to null
, Design Automation throws an error.
Response
{
"id": "YOUR_NICKNAME.ConfigureDesignActivity",
"engine": "Autodesk.Fusion+Latest",
"appbundles": [
"YOUR_NICKNAME.ConfigureDesignActivity+my_working_version"
],
"settings": {},
"description": "",
"version": 2
}
Step 4 - Assign an existing alias to the updated Activity
NOTE: Perform this step only if you carried out Step 3
Currently, the alias current_version points to version 1 of the Activity.
id | alias | version |
---|---|---|
ConfigureDesignActivity | current_version | 1 |
ConfigureDesignActivity | 2 |
You can reassign the alias current_version to point to version 2 of the Activity.
id | alias | version |
---|---|---|
ConfigureDesignActivity | 1 | |
ConfigureDesignActivity | current_version | 2 |
To update the alias, you can either:
- Delete the existing alias and recreate it with the version you want to label.
- Send a PATCH request.
To send a PATCH request:
Request
curl -X PATCH \
'https://developer.api.autodesk.com/da/us-east/v3/activities/ChangeParamActivity/aliases/my_current_version' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
-d '{
"version": 2
}'
Notes:
version
- Refers to the version number the alias labels.