NOTE: PowerShell 7.0 or greater is a prerequisite to making use of this script.
There are many different ways to interact with the IriusRisk API. In this example, we'll be using PowerShell to make a request to the /api/v1/products/mtmt POST endpoint to import a project based on the Open Threat Model standard.
Here's the script we'll be using:
$uri = 'https://example.iriusrisk.com/api/v1/products/mtmt'
$headers = @{
'accept' = 'application/json'
'api-token' = 'your-token-here'
'content-type' = 'multipart/form-data'
}
$form = @{
'tm7-file' = Get-Item -Path 'C:\Example\ExampleThreatModel.tm7'
'product-id' = 'example'
'name' = 'your-project-name-here'
}
Invoke-RestMethod -Uri $uri -Method 'POST' -Headers $headers -Form $form -verbose
In this script, replace the the placeholder example values with the values corresponding to your own installation of IriusRisk. You can either paste the script directly into a PowerShell 7.0 prompt, or into an IDE that supports .ps1 files, such as VSCode.
After being run, your project should now be listed under your Projects, identifiable by the project name you gave it in the script.
If you receive an error message similar to this one:
PS C:\WINDOWS\system32> Invoke-RestMethod -Uri $uri -Method 'POST' -Headers $headers -Form $form -verbose
Invoke-RestMethod : A parameter cannot be found that matches parameter name 'Form'.
At line:1 char:62
Then you're using a PowerShell version <7.0 and will need to install the latest version of PowerShell 7.
Comments
0 comments
Please sign in to leave a comment.