Macro for Assets can be read/edited via API, to automate creation of pages.
This is not available on Dashboard gadget for Assets.
Available APIs
Method | URI | Query Params | Token Scope | Token Space(s) | Description |
---|---|---|---|---|---|
GET | api_url | pageId token |
| can be limited using space list or empty to allow all spaces. | Returns an array of Macro for Assets configuration for a specific page using pageId param. GET instance_url/macro?pageId=1234 |
PUT | api_url | pageId token |
| can be limited using space list or empty to allow all spaces. | Updates all Macro for Assets configuration specified in the body for a specific page using pageId param. Use GET on a page to fetch format of a macro configuration. PUT instance_url/macro?pageId=1234 [ { "id": "rxt-95ae25ba-0759-4b4e-a40f-edbdc7194067", "configuration": { "columns": [], "iql": "objectType=\"Jira Users\"", "displayAs": "AS_TABLE", "pageSize": 5, "schemaId": "4", "connectionId": "45157a8a-79ad-46f7-b920-c21211bf79ec", "tableOptions": { "linksEnabled": true, "downloadEnabled": false, "printEnabled": false } } } ] |
POST | api_url | spaceKey token |
| can be limited using space list or empty to allow all spaces. | Creates one or more new page(s) with Macro for Assets added and pre-configured. spaceKey determine what space to add the page in. Body takes an array of pages title and parent with macro configuration. Example; POST instance_url/page?spaceKey=ABC [ { "title":"Page title", "parentPageId":"id of parent page or null on root level", "macros":[ { "id": "rxt-95ae25ba-0759-4b4e-a40f-edbdc7194067", "configuration": { "columns": [], "iql": "objectType=\"Jira Users\"", "displayAs": "AS_TABLE", "pageSize": 5, "schemaId": "4", "connectionId": "45157a8a-79ad-46f7-b920-c21211bf79ec", "tableOptions": { "linksEnabled": true, "downloadEnabled": false, "printEnabled": false } } } ] } ] |
POST | api_url/copy | spaceKey pageId token |
| can be limited using space list or empty to allow all spaces. | Copies one or more new page(s) with Macro for Assets added and pre-configured. spaceKey determine what space to add the page in. Body takes an array of pages with macro configuration Example; POST instance_url/page/copy?spaceKey=ABC [ { "title":"Page title", "parentPageId":"id of parent page or null on root level", "macros":[ { "id": "rxt-95ae25ba-0759-4b4e-a40f-edbdc7194067", "configuration": { "columns": [], "iql": "objectType=\"Jira Users\"", "displayAs": "AS_TABLE", "pageSize": 5, "schemaId": "4", "connectionId": "45157a8a-79ad-46f7-b920-c21211bf79ec", "tableOptions": { "linksEnabled": true, "downloadEnabled": false, "printEnabled": false } } } ] } ] |
Steps to get started
Go to Manage Apps → Macro for Assets
Click the API tab.
To enable API access you need to generate an access token.
Click the Generate Access Token - button to generate one or more tokens.
By default the access token will be applicable for all projects with Read and Write permissions.
Click the Edit link to edit token permissions
Get Macro for Asset configuration and IDs via API
Make a HTTP GET request to the URL available on your API page.
Use this API when you need to retreive a Macro for Assets configuration.
Required parameters:
token = the access token (scope must be READ and projects must match issue project)
pageId = the page to read macro configuration values from
Response:
200 OK (application/json) When request is valid
Body:
[ { "id":"..." }, ]
400 BAD REQUEST When request is invald
Body:
Error message
Note: Verify parameters to resolve this issue
401 UNAUTHORIZED When request is unauthorized.
Body:
Error message
Note: Verify access token permissions to resolve this issue
Update Macro for Asset configuration via API
Make a HTTP PUT (or POST) request to the URL available on your API page.
Use this API when you want to update Macro for Assets configuration on a page.
You can read the current macro config using the GET api and then use those IDs to update the macro configuration using this endpoint.
Required parameters:
token = the access token (scope must be WRITE and projects must match issue project)
pageId = the page to store the macro config on values from
Required post body:
An array of field entities, use multiple entities to update multiple field values. Note: To update a single value this still has to be an array containing the single value entity.
[ { macro config.... } ]
Response:
200 OK When request is valid and value was updated
Body: OK
400 BAD REQUEST When request is invalid
Body:Bad Request
Note: Verify parameters to resolve this issue
401 UNAUTHORIZED When request is unauthorized.
Body: Unauthorized
Note: Verify access token permissions to resolve this issue
401 BAD REQUEST When request is unauthorized.
Body:Bad Request
Note: Make sure the that the project(s) has Edit Permission: atlassian-addons-project-access
Check that the Field exists on the edit screen.
Create Page with Macro for Asset configuration via API
Make a HTTP PUT (or POST) request to the URL available on your API page.
Use this when you want to programatically create a page with the Macro for Asset on it with pre-configured settings.
Required parameters:
token = the access token (scope must be WRITE and projects must match issue project)
pageId = the page to store the macro config on values from
Required post body:
An array of field entities, use multiple entities to update multiple field values. Note: To update a single value this still has to be an array containing the single value entity.
[ { macro config.... } ]
Response:
200 OK When request is valid and value was updated
Body: OK
400 BAD REQUEST When request is invalid
Body:Bad Request
Note: Verify parameters to resolve this issue
401 UNAUTHORIZED When request is unauthorized.
Body: Unauthorized
Note: Verify access token permissions to resolve this issue
401 BAD REQUEST When request is unauthorized.
Body:Bad Request
Note: Make sure the that the project(s) has Edit Permission: atlassian-addons-project-access
Check that the Field exists on the edit screen.