Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Upload BOM to Dependency-Track using PUT method
try {
$xml = Get-Content (Join-Path $PSScriptRoot ".\bom.xml") -Raw
$ProjectGuid = "d78bc750-d6db-4805-9836-5d77075ec37a"
$ApiKey = "6Ue2f8uVfRiVGpdowjWfF3yW02ryA7Uc"
$Uri = "http://localhost:8080"
$Body = ([PSCustomObject] @{
project = $ProjectGuid
bom = ([Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($xml)))
} | ConvertTo-Json)
$Header = @{ 'X-API-Key' = $ApiKey }
Invoke-RestMethod -Method Put -Uri "$Uri/api/v1/bom" -Headers $Header -ContentType "application/json" -Body $Body
catch {
Write-Host $_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment