-
- Novice
- Posts: 4
- Liked: never
- Joined: Feb 27, 2015 9:06 pm
- Contact:
Get vmRestorePoint by vmDisplayName with periods
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?
restHost.createRequest("GET", "/query?type=vmrestorepoint&filter=vmdisplayname==" + vmName, null).execute();
Is there a way to match instead of equal?
-
- Product Manager
- Posts: 20389
- Liked: 2298 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Get vmRestorePoint by vmDisplayName with periods
Might be a silly question, but is vmName parameter contains opening and ending quotes, something like "VMName.User1"?
-
- Novice
- Posts: 4
- Liked: never
- Joined: Feb 27, 2015 9:06 pm
- Contact:
Re: Get vmRestorePoint by vmDisplayName with periods
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.
Every VM in our VMware environment is named its FQDN.
-
- VP, Product Management
- Posts: 6035
- Liked: 2860 times
- Joined: Jun 05, 2009 12:57 pm
- Full Name: Tom Sightler
- Contact:
Re: Get vmRestorePoint by vmDisplayName with periods
Did you try to escape the quote? I think I ran into this and I just used the escape function, something like:
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.
Code: Select all
restHost.createRequest("GET", escape("/query?type=vmrestorepoint&filter=(vmdisplayname==\"" + vmName + "\")"), null).execute()
-
- Novice
- Posts: 4
- Liked: never
- Joined: Feb 27, 2015 9:06 pm
- Contact:
Re: Get vmRestorePoint by vmDisplayName with periods
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:
note that the quotes were required
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()
Who is online
Users browsing this forum: No registered users and 3 guests