REST API knowledge exchange
Post Reply
Dandys3900
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2024 4:50 am
Full Name: Timmy Trumpet
Contact:

Veeam API Full VM Restore non-Virtual Machine folder error

Post by Dandys3900 »

Basically I'm trying to perform full VM restore using latest Veeam REST API.
Used endpoint:

Code: Select all

/api/v1/restore/vmRestore/vSphere
The issue is that, according to created restoreVM task logs, I'm getting following issue:
Virtual Machine cannot be registered in a non-Virtual Machine folder.

What I've observed so far is that when listing available server inventory objects, I'm getting different folder than available using UI restore wizard directly at Veeam server (via UI I can see correct folder) (for accessing Veeam UI, I'm using separate Admin account)

The endpoint I'm using:

Code: Select all

/api/v1/inventory/{hostname}
Initially I was blaming diff in access rights for API and Admin account, but both have Veeam Backup Administrator role assigned.

Does anyone experienced something similar? Any ideas?
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by david.domask »

Hi Timmy, welcome to the forums.

Just to confirm, you're doing a restore to a new location and when using the EntireVmRestoreVmware endpoint, you're hitting this error? Did you first fetch the Folder resource as a target?

Can you maybe share your code (removing any sensitive information like credentials/hostnames/ips)? Also you're using v1 of the API intentionally or just perhaps following instructions elsewhere that used v1 API?
David Domask | Product Management: Principal Analyst
Dandys3900
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2024 4:50 am
Full Name: Timmy Trumpet
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by Dandys3900 »

Hi there,
yes, using provided endpoint I'm getting mentioned error. Can You elaborate more about "fetching Folder resource as target" please? All I'm doing is using following endpoint to get all available inventory objects -https://helpcenter.veeam.com/docs/backu ... oryObjects

Then I list all objects where "type" is "Folder" and I directly pass this to body of restore VM command.
I'm using version 1.1-rev1 intentionally.
Brief overview of my Python code:

Code: Select all

retVal = veeam.post("v1/restore/vmRestore/vSphere", {
        "restorePointId": "someValue",
        "type"          : "Customized",
        "restoreProxies": {
            "autoSelectEnabled": True,
            "proxyIds"         : []
        },
        "secureRestore": {
            "antivirusScanEnabled"   : False,
            "virusDetectionAction"   : "",
            "entireVolumeScanEnabled": False
        },
        "powerUp"      : False,
        "reason"       : "Test restore",
        "quickRollback": False,
        "destinationHost": inv_objs.get("Host"),
        "resourcePool"   : inv_objs.get("ResourcePool"),
        "datastore": {
            "datastore": inv_objs.get("Datastore"),
            "diskType" : "Source"
        },
        "folder": {
            "vmName"       : "newUniqueName",
            "folder"       : inv_objs.get("Folder"),
            "restoreVmTags": True
        },
        "network": {
            "network": inv_objs.get("Network"),
            "disconnected": True
        }
    })
where inv_objs is dictionary with received Inventory objects.
Thanks in advance!
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by david.domask »

Got it, you should be able to fetch the desired folder information from the Inventory Browser. Find the necessary folder (you can filter your query results with this endpoint), and then ensure a specific folder is passed to the EntireVmRestoreVmware endpoint as shown in the example. It kind of sounds like maybe multiple elements from your call from the Inventory Browser, but it should just be a single folder you're targeting.
David Domask | Product Management: Principal Analyst
Dandys3900
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2024 4:50 am
Full Name: Timmy Trumpet
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by Dandys3900 »

Well, that's exactly what I originally did David. I used provided endpoint to list all available inventory objects, and there is only one object of type "Folder", and so I used this object in request body of restoreVM endpoint as can be seen from provided code snippet. The thing is, apart from gettig mentioned error, I also see different folders using REST API call - https://helpcenter.veeam.com/docs/backu ... oryObjects and when using restore wizard in Veeam GUI, even for the same user.

Letme show You...
According to a Veeam GUI, on the given hostname, there are multiple folders (namely: Project, APITest,...), but this is the only folder I got from API call:

Code: Select all

{
      "type": "Folder",
      "hostName": "VALUE",
      "name": "host",
      "objectId": "group-h4",
      "urn": "vc:VALUE;folder:group-d1;datacenter:datacenter-2;folder:group-h4",
      "platform": "VMware",
      "size": "N/A"
}
(and yes, the hostname is the same as in GUI folder structure)

and when using provided "Folder" object for VM restore, I got already mentioned error.
I hope this helps :-D
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by david.domask »

Got it, thank you for confirming, just wanted to make sure we weren't missing anything "basic" :)

At this stage, I'd ask if you could reproduce the issue and open a Support Case -- Support can check the logs for the API and see why this is being triggered -- the message is fairly clear, but if you're certain it's a correct folder, then it's best to let Veeam Support review.

Be sure to include logs from the Veeam server for Support to review. (Use the 3rd radio option and select the Veeam server itself, and please note in your case the date/time of the reproduction)

Please share the case number here once you have it. Thanks!
David Domask | Product Management: Principal Analyst
Dandys3900
Novice
Posts: 4
Liked: never
Joined: Aug 28, 2024 4:50 am
Full Name: Timmy Trumpet
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by Dandys3900 »

Hi there,
sorry for being absent here, requested ticket number is #07397254

Enjoy Your day :-)
david.domask
Veeam Software
Posts: 2123
Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Veeam API Full VM Restore non-Virtual Machine folder error

Post by david.domask »

Just to follow up, looks like what we were missing is adding hierarchyType to the request body of the POST request.

In this case you need to set "hierarchyType": "VmsAndTemplates" to get inventory objects with type folder. Or, to just get folders:

Code: Select all

{
    "filter": {
        "type": "PredicateExpression",
        "property": "type",
        "operation": "equals",
        "value": "Folder"
    },
    "hierarchyType": "VmsAndTemplates"
}
https://helpcenter.veeam.com/docs/backu ... &t=request
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests