RESTful knowledge exchange
Post Reply
infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

API Query for AgentRestorePoints

Post by infraerik » Aug 29, 2019 10:42 am

Hi there,

Just wondering if there's any way to query the API for either generic restore points or specifically AgentRestorePoints in the same way you can with VmRestorePoints. I just observed that in my reports, Agents are not being found.

This works perfectly for my regular VM backups:
$response = Invoke-WebRequest -Uri "http://xxx:9399/api/query?type=VmRestor ... eationTime" -Method "GET" -Headers @{"X-RestSvcSessionId" = $sessionId }

But if I use AgentRestorePoint, it errors on the filter of VmName and it doesn't recognize AgentName as a valid filter criteria either. The documentation is unclear on what attributes are available for any given object for filtering purposes (although that may just be me missing something)

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Aug 29, 2019 11:00 am

Whoops - for readability, here's the extracted request string:

api/query?type=VmRestorePoint&filter=VmName==$server&format=entities&sortDesc=CreationTime

Vitaliy S.
Product Manager
Posts: 22984
Liked: 1556 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: API Query for AgentRestorePoints

Post by Vitaliy S. » Aug 29, 2019 2:44 pm

I believe this is not available due to these reasons > Agent Jobs Via API

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Aug 29, 2019 3:42 pm

I think that may have been changed in an update since that discussion since I *can* extract AgentRestorePoints en masse via the API and according to the documentation (https://helpcenter.veeam.com/docs/backu ... l?ver=95u4) AgentRestorePoints are listed in the Query API as being valid resources to request via this API. There's now an endpoint at api/agents/jobs.

But there's absolutely nothing in the documentation concerning what attributes can be used for filtering for any of the ressources available via the Query interface. Even the VMName filter that I use for regular VM Backups was found by trawling through the forums.

veremin
Product Manager
Posts: 16884
Liked: 1433 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: API Query for AgentRestorePoints

Post by veremin » Aug 30, 2019 4:40 pm 2 people like this post

The following parameters are supported as querying filters for agent restore points:

Code: Select all

  "Uid";
  "Name";
  "CreationTime";
  "ComputerName";
  "Type";
  "Algorithm";
  "RestorePointId";
  "RestorePointName";
  "BackupUid";
  "BackupName";
  "BackupServerUid";
  "BackupServerName";
  "BackupFileUid";
  "BackupFileName";
Thanks!

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Sep 02, 2019 6:16 am

Thanks ! That’s really useful information.

Any chance we could see updates to the documentation to include this information for each of the queryable objects?

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Sep 02, 2019 8:04 am

OK - now onto the next related problem. When I use the ComputerName for filtering, it works as long as the computer in question was registered via it's hostname, but if I have an agent registered using it's FQDN, I get this error when trying to search:

Code: Select all

Invoke-WebRequest : <?xml version="1.0" encoding="utf-8"?><Error Message="Malformed expression string:
ComputerName==xxx.yyy.zzz.local" StatusCode="400" xmlns="http://www.veeam.com/ent/v1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
At reporting_functions.ps1:432 char:17
+ ... $response = Invoke-WebRequest -Uri $uri -Method "GET" -Headers @{"X-R ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
I've tried URI encoding the FQDN with %2E, but I'm still getting the same errors. Outside of going back and unregistering all of the agents and reregistering them using just the hostname, is there an encoding that the API will accept for querying agents by their full name?

benyoung
Service Provider
Posts: 124
Liked: 34 times
Joined: May 25, 2016 3:29 am
Full Name: Ben Young
Contact:

Re: API Query for AgentRestorePoints

Post by benyoung » Sep 03, 2019 12:22 am

If i recall, you can wrap the VmName in quotes, i.e

/api/query?type=VmRestorePoint&filter=VmName=="xxx.yyy.zzz.local"&format=entities&sortDesc=CreationTime

I dont have any servers with that type of hostname data but can replicate the malformed error, goes away if i wrap it in quotes (and returns the same result for servers i have without FQDN if quotes are there or not)

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Sep 03, 2019 6:46 am

Good timing, I had just figured that trick with the quotes about 30 minutes before seeing your reply. Next step: trying to figure out why the syntax I use for extracting date from the most recent restorepoint that I use for VMRestorePoints doesn't seem to work on the AgentRestorePoints...

$lastbackup = ([datetime]([xml]$response.Content).QueryResult.Entities.AgentRestorePoints.AgentRestorePoint.CreationTimeUTC[0]).ToLocalTime()

vs

$lastbackup = ([datetime]([xml]$response.Content).QueryResult.Entities.VmRestorePoints.VmRestorePoint.CreationTimeUTC[0]).ToLocalTime()

But at least I'm getting data back from the API now.

Side note for dealing with the problem that my input list for servers to check comes as a hostname, my current workaround is to pull out all of the api/agents/discoveredComputers and build a hash out of the value keyed on the hostname part of the name with the value of whatever is used, whether it's an FQDN or a hostname.

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Sep 03, 2019 7:03 am

Huh - and now it works this morning. Go figure.

veremin
Product Manager
Posts: 16884
Liked: 1433 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: API Query for AgentRestorePoints

Post by veremin » Sep 03, 2019 3:28 pm

infraerik wrote:
Sep 02, 2019 6:16 am
Any chance we could see updates to the documentation to include this information for each of the queryable objects?
Actually, we already have this information in User Guide. You can find it here. Thanks!

infraerik
Influencer
Posts: 11
Liked: never
Joined: Jul 24, 2019 10:04 am
Contact:

Re: API Query for AgentRestorePoints

Post by infraerik » Sep 16, 2019 1:23 pm

@veremin, Uhhh, the list you presented earlier in the thread does not match up with the list of attributes noted on the documentation page. The documentation page makes reference to VMDisplayName rather than ComputerName...

veremin
Product Manager
Posts: 16884
Liked: 1433 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: API Query for AgentRestorePoints

Post by veremin » Sep 18, 2019 7:39 pm

Got it, will correct the documentation soon (already notified tech writing team). Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest