Skip to main content

Delete Archives

Thread needs solution
Posts: 6
Comments: 9


I would like to delete all archives before each execution of a specific plan as a pre-job.

Postman return me those query parameters :



I get all information required like that :

$Locations = Invoke-RestMethod -Method "GET" -Uri "${baseUrl}bc/api/vault_manager/v1/vaults?count=1&includeStats=true&limit=30&order=asc(name)" -Headers $headers -ContentType "application/json"

$Location = $Locations.items | Select-Object {$_.uri}, {$}, {$_.managing_agent_id} | where {$_.uri} -like "*usbshare1*"

$VaultId = $Location.'$'
$MachineId = $Location.'$_.managing_agent_id'

$Archives = Invoke-RestMethod -Method "GET" -Uri "${baseUrl}bc/api/vault_manager/v1/vaults/$VaultId/archives" -Headers $headers -ContentType "application/json"

$ArchivesId = $Archives.items | Select-Object {$_.legacy_id}

$ArchivesId = $ArchivesId.'$_.legacy_id'[0]


Put every parameters in a body :

$paramarchives = @"


"archiveId": "$ArchivesID",
"machineId": "$MachineId",
"operationId": "va-rem-1-7",
"subscriptionId": "1",



And then try to delete in that case a single archive to test it ($ArchivesId.'$_.legacy_id'[0]) : 

$Archives = Invoke-RestMethod -Method "DELETE" -Uri "${baseUrl}bc/api/ams/archives/" -Headers $headers -ContentType "application/json" -Body $paramarchives

I also tried to delete archive like that without any success : 

$Archives = Invoke-RestMethod -Method "DELETE" -Uri "${baseUrl}bc/api/ams/archives/%3CpatharchiveId%3E?archiveId=$ArchivesID&machineId=$MachineId&subscriptionId=5&operationId=va-rem-5-1" -Headers $headers -ContentType "application/json"


Each time powershell console tell me that : 

Invoke-RestMethod : {"reason":"wcsInternalError","origin":"_delete_archive_by_key_arg() missing 1 required positional argument: 
'machineId'","effect":null,"context":{"_internal":"100011:-1:-1"},"date":"2020-07-16T11:40:39.417414+00:00","troubleshoot":null,"cause":"Internal server error."}
Au caractère C:\temp\acronis_suppression_backups_api.ps1:217 : 13
+ $Archives = Invoke-RestMethod -Method "DELETE" -Uri "${baseUrl}bc/api ...

Can someone help me with that ?




0 Users found this helpful
Forum Member
Posts: 3
Comments: 82

As I remember for most of these calls you are required to put the same parameters both to an URL and a body to have a successful call.

Just to mention, that it's not a public API, thus it might be changed without notice.

Posts: 6
Comments: 9

Ok thank you for you answer.

Also I noticed slight difference between the request that I have thanks to archives items (legacy_id) : 

"/bc/api/ams/archives/%3CpatharchiveId%3E?archiveId=smb:/" -Headers $headers -ContentT"

And the one from my postman request : 


Values changing between : ":/" to "%3A%2F" ; "/" to "%2F".

Do you have something that can do the trick or request the second value in another way ?


I succeeded to pass the machineid not found error with the percent-encoding : $ArchivesID = [System.Web.HttpUtility]::UrlEncode("$ArchivesID")


But now it said that "subscriptionID" is not found :

Invoke-RestMethod : {"reason":"wcsSubscriptionNotFound","stacktrace":null,"effect":null,"context":{"_internal":"100005:-1:-1","sub_id":"3"},"date":"2020-07-17T08:36:49.905596+00:00","troubleshoot":null,"cause":"Subscription with id \"3\" not 


I didn't found somewhere to look for in order to get this value related to each archives.

Also the some for "operationId"

Do you now where I can find those specific values ?


EDIT 2 : 

I found out that both last paramaters are not "required" so everything working fine now.




Forum Member
Posts: 3
Comments: 82


To use subscription, you need to create it before the first call with all these API, with that you receive all updated values in case they are, with call for subscription by subscription id.