When working with data for a specific Project like Issues or Attachments, make sure to define the Dradis-Project-Id HTTP header like so:
$ curl \ -H 'Authorization: Token token="xMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ https://dradis-pro.dev/pro/api/nodes/8/attachments
GET /pro/api/nodes/:node_id/attachmentsRetrieves all the Attachments associated with the specific Node in your project.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ http://dradis-pro.dev/pro/api/nodes/8/attachments
Result:
[
{
"filename": "file%201.png",
"link": "/pro/projects/3/nodes/8/attachments/file%201.png"
},
{
"filename": "file%202.csv",
"link": "/pro/projects/3/nodes/8/attachments/file%202.csv"
}
]
GET /pro/api/nodes/:node_id/attachments/:filenameRetrieves a single attachment from a Node in your project.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ http://dradis-pro.dev/pro/api/nodes/8/attachments/file%201.png
Result:
{
"filename": "file 1.png",
"size": 19331,
"created_at": "2024-05-17T15:53:33.514-03:00",
"link": "/pro/projects/3/nodes/8/attachments/file%201.png",
"download": "http://dradis-pro.dev/pro/api/nodes/8/attachments/file%201.png/download"
}
You can also download an attachment using the API.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ -o file%201.png http://dradis-pro.dev/pro/api/nodes/8/attachments/file%201.png/download
POST /pro/api/nodes/:node_id/attachmentsCreates an Attachment on the specified Node in your project. The files to be the attached must be provided in the POST using using the Content-Type: multipart/form-data.
HTTP status 201 will be returned if the creation completes successfully.
| Accepted Parameter | Use |
|---|---|
files[] |
Pass it the files to be uploaded, as a web browser does with an input of type field. More than 1 Attachment can be created on a single request. |
Sample request:
curl \
-H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \
-H 'Dradis-Project-Id: 3' \
-H 'Content-Type: multipart/form-data' \
-X POST \
-F 'files[]=@/your/own/path/file 1.png' -F 'files[]=@/your/own/path/file 1.png' \
http://dradis-pro.dev/pro/api/nodes/8/attachments
Result:
[
{
"filename": "file 1.png",
"link": "/pro/projects/3/nodes/8/attachments/file%201.png"
},
{
"filename": "file 1_copy-01.png",
"link": "/pro/projects/3/nodes/8/attachments/file%201_copy-01.png"
}
]
PUT /pro/api/nodes/:node_id/attachments/:filenameRenames a specific Attachment on a Node in your project. The new name to must be provided in the body as JSON.
HTTP status 200 will be returned if the update completes successfully.
Sample request:
curl \
-H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \
-H 'Dradis-Project-Id: 3' \
-H 'Content-type: application/json' \
-X PUT \
-d '{"attachment":{"filename": "new_name.png" }}' \
http://dradis-pro.dev/pro/api/nodes/8/attachments/file%201.png
Result:
{
"filename": "new_name.png",
"link": "/pro/projects/3/nodes/8/attachments/new_name.png"
}
DELETE /pro/api/node/:node_id/attachments/:filenameDeletes an Attachment from the specified Node in your project. HTTP status 200 will be returned if the deletion completes successfully.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ -H 'Content-type: application/json' \ -X DELETE \ http://dradis-pro.dev/pro/api/nodes/8/attachments/file%201.png
Result:
{
"message": "Resource deleted successfully"
}
Next help article: Document Properties endpoint →
Your email is kept private. We don't do the spam thing.