Macro for Assets can be read/edited via API, to automate creation of pages. This is not available on Dashboard gadget for Assets.
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.