The projects can be exported via API through the end point /api/v1/products/{product-id}.
The "Response content type" needs to be set to application / xml, and the output of the call redirected to a file.
For example, we can create an executable script named export_project.sh, with the API call:
curl -X 'GET' \
'https://<_URL_here>.iriusrisk.com/api/v1/products/<_Add_the_desired_project_ID_here_>' \
-H 'accept: application/xml' \
-H 'api-token: <_Add_your_token_here_>'
And then redirect the output of the API call to a file when launching the script:
$ sh export_project.sh > exported_project.xml
The feature can be used for other purposes as well, like for example to have the projects backed up externally, using something like this python script:
import requests
from requests.structures import CaseInsensitiveDict
import datetime
instance = "<_Your_instance_>.iriusrisk.com"
project_id = "<_Your_project_id_>"
api_token = "<_Your_token_>"
endpoint = "/api/v1/products/"
time = datetime.datetime.now().strftime("%m%d%Y_%H%M%S")
url = f"https://{instance}{endpoint}{project_id}"
headers = CaseInsensitiveDict()
headers["accept"] = "application/xml"
headers["api-token"] = api_token
resp = requests.get(url, headers=headers)
if resp.status_code != 200:
print (resp.status_code)
print (resp.text)
else:
backup = open(f"backup_{project_id}_{time}.xml","w")
backup.write(resp.text)
backup.close()
Comments
0 comments
Article is closed for comments.