When working with data for a specific Project like Content Blocks, 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/content_blocks/
GET /pro/api/content_blocks
Retrieves all of the Content Blocks in your project, ordered by the Content Block id
, ascending.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ http://dradis-pro.dev/pro/api/content_blocks
Result:
[ { "id": 4, "author": "admin@securityroots.com", "block_group": "Conclusions", "title": "Conclusions and Recommendations", "fields": { "Title": "Conclusions and Recommendations", "Type": "Conclusions", "Description": "Any data you put in this Description field will export out into the Conclusions and Recommendations section of your welcome pack report template." }, "content": "#[Title]#\r\nConclusions and Recommendations\r\n\r\n#[Type]#\r\nConclusions\r\n\r\n#[Description]#\r\nAny data you put in this Description field will export out into the Conclusions and Recommendations section of your welcome pack report template. " }, { "id": 5, "author": "admin@securityroots.com", "block_group": "Appendix", "title": "Example Appendix Content", "fields": { "Title": "Example Appendix Content", "Type": "Appendix", "Description": "Any data you put in this Description field will export out into Appendix B of your welcome pack report template." }, "content": "#[Title]#\r\nExample Appendix Content\r\n\r\n#[Type]#\r\nAppendix\r\n\r\n#[Description]#\r\nAny data you put in this Description field will export out into Appendix B of your welcome pack report template." } ]
GET /pro/api/content_blocks/:block_id
Retrieves a single Content Block from your project.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ http://dradis-pro.dev/pro/api/content_blocks/4
Result:
{ "id": 4, "author": "admin@securityroots.com", "block_group": "Conclusions", "title": "Conclusions and Recommendations", "fields": { "Title": "Conclusions and Recommendations", "Type": "Conclusions", "Description": "Any data you put in this Description field will export out into the Conclusions and Recommendations section of your welcome pack report template." }, "content": "#[Title]#\r\nConclusions and Recommendations\r\n\r\n#[Type]#\r\nConclusions\r\n\r\n#[Description]#\r\nAny data you put in this Description field will export out into the Conclusions and Recommendations section of your welcome pack report template." }
POST /pro/api/content_blocks
Creates a Content Block in your project. The attributes for the Content Block must be provided in the POST body as JSON.
HTTP status 201
will be returned if the creation completes successfully, and a Location
header will be sent with the response, set to the URL of the newly created resource.
Accepted Parameter | Use |
---|---|
content_block |
Pass it the text parameter. |
content |
Pass it the content of the Content Block using JSON on one line subbing in \r\n for new lines. Don't forget to include field names with the #[ ]# syntax. |
block_group (optional) |
Pass this the name of the Block Group you want to assign to your Content Block. For example, pass it a value of Conclusions to set your Content Block to the Conclusions Block Group you've defined in your Report Template Properties. |
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ -H 'Content-type: application/json' \ -X POST \ -d '{"content_block": {"content": "#[Title]#\r\nNew Content Block\r\n\r\n#[Description]#\r\nSample content.", "block_group": "Conclusions"}}' \ http://dradis-pro.dev/pro/api/content_blocks
Result:
{ "id": 6, "author": "admin@securityroots.com", "block_group": "Conclusions", "title": "New Content Block", "fields": { "Title": "New Content Block", "Description": "Sample content." }, "content": "#[Title]#\r\nNew Content Block\r\n\r\n#[Description]#\r\nSample content." }
PUT /pro/api/content_blocks/:block_id
Updates a specific Content Block in your project. The attributes to be updated must be provided in the body as JSON. Like the POST method, make sure to write out the new content of the Content Block using JSON on one line subbing in \r\n
to create new lines create fields using the #[ ]#
syntax.
HTTP status 200
will be returned if the update completes successfully.
See POST
above for more details on the accepted parameters.
Sample request:
curl \ -H 'Authorization: Token token="hxMsNwttqN5bVNEYcrIF01s65"' \ -H 'Dradis-Project-Id: 3' \ -H 'Content-type: application/json' \ -X PUT \ -d '{"content_block": {"content": "#[Title]#\r\nUpdated Content Block\r\n\r\n#[Description]#\r\nUpdated content.", "block_group": "Conclusions"}}' \ http://dradis-pro.dev/pro/api/content_blocks/6
Result:
{ "id": 6, "author": "admin@securityroots.com", "block_group": "Conclusions", "title": "Updated Content Block", "fields": { "Title": "Updated Content Block", "Description": "Updated content." }, "content": "#[Title]#\r\nUpdated Content Block\r\n\r\n#[Description]#\r\nUpdated content." }
DELETE /pro/api/content_blocks/:block_id
Deletes a specific Content Block from 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/content_blocks/6
Result:
{ "message": "Resource deleted successfully" }
Next help article: Notes endpoint →
Your email is kept private. We don't do the spam thing.