Get vmRestorePoint by vmDisplayName with periods

RESTful knowledge exchange

Get vmRestorePoint by vmDisplayName with periods

Veeam Logoby pizzle85 » Mon Jul 20, 2015 6:54 pm

Im attempting to perform a query to pull all vmRestorePoints based off the display name of the VM assoicated with the restore point. When the VM name contains periods the API throws an error about the period being an illegal character. Does anyone know if there is a way to get this to work or a better way to pull all restore points based off some VM information (ID, NAME, etc)?

restHost.createRequest("GET", "/query?type=vmrestorepoint&filter=vmdisplayname==" + vmName, null).execute();

Is there a way to match instead of equal?
pizzle85
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 27, 2015 9:06 pm

Re: Get vmRestorePoint by vmDisplayName with periods

Veeam Logoby v.Eremin » Tue Jul 21, 2015 10:09 am

Might be a silly question, but is vmName parameter contains opening and ending quotes, something like "VMName.User1"?
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Get vmRestorePoint by vmDisplayName with periods

Veeam Logoby pizzle85 » Tue Jul 21, 2015 12:35 pm

I attempted it using double and single quotes, it didn't make a difference. It always complains about the period.

Every VM in our VMware environment is named its FQDN.
pizzle85
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 27, 2015 9:06 pm

Re: Get vmRestorePoint by vmDisplayName with periods

Veeam Logoby tsightler » Tue Jul 21, 2015 3:56 pm 2 people like this post

Did you try to escape the quote? I think I ran into this and I just used the escape function, something like:
Code: Select all
restHost.createRequest("GET", escape("/query?type=vmrestorepoint&filter=(vmdisplayname==\"" + vmName + "\")"), null).execute()

This string escapes the outer set of the double quotes so that it's part of the literal string, then concatenates the VM name, then encodes the special characters (like the quote marks themselves) in the resulting URL. I guess I'm supposed to be using encodeURI() instead of escape() these days, but I'm old school. I believe that this will work as it definitely works for FQDN hostnames, but I haven't specifically tried it with VM names.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: Get vmRestorePoint by vmDisplayName with periods

Veeam Logoby pizzle85 » Tue Jul 21, 2015 5:00 pm

awesome, what you sent worked like a charm. I suppose it was just a lack of knowledge on my part. Thanks for the quick help!

This is what i ended up using:

Code: Select all
var uri = encodeURI("/query?type=vmrestorepoint&filter=vmdisplayname==\"" + vmName + "\"");
var restorePointsXML = restHost.createRequest("GET", uri, null).execute()


note that the quotes were required
pizzle85
Novice
 
Posts: 4
Liked: never
Joined: Fri Feb 27, 2015 9:06 pm


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 2 guests