add vm to backup job

RESTful knowledge exchange

add vm to backup job

Veeam Logoby opoet » Sun Aug 09, 2015 1:24 pm

hello

how to add a vm to backup job?

i use this code
POST http://<Enterprise-Manager>:9399/api/jobs/{ID}/includes
but i get error 500 when run that.
opoet
Lurker
 
Posts: 2
Liked: never
Joined: Sun Aug 09, 2015 1:20 pm
Full Name: Tami

Re: add vm to backup job

Veeam Logoby PTide » Mon Aug 10, 2015 3:04 pm 1 person likes this post

Hi,

Is it the only command that does not work? Do you have a little bit more details on that issue?

Thank you.
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: add vm to backup job

Veeam Logoby tsightler » Mon Aug 10, 2015 4:56 pm 1 person likes this post

That's certainly the correct URL, but of course the request body must include a properly formatted XML schema with the required parameters properly defined. Perhaps you can share a little more of your code as to how you are building the request body.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: add vm to backup job

Veeam Logoby opoet » Sat Aug 15, 2015 1:46 pm

Thank you for reply
I have a problem to send rest api body parameters to veeam i solved it and it's work corectlly
opoet
Lurker
 
Posts: 2
Liked: never
Joined: Sun Aug 09, 2015 1:20 pm
Full Name: Tami

Re: add vm to backup job

Veeam Logoby ameyerhoff » Thu May 05, 2016 7:25 pm

I have a similar issue: SUPPORT CASE: "Veeam Support - Case # 01791212 - obscure error msg when adding vm to backup job in web api"
I'm using VBR version 9.0. FYI I will be obscuring the base of all shown urls as {{server}}

I attempted to add a vm to a job and the generated task failed with the message: 'Object reference not set to an instance of an object.'

The request body is built with information retrieved from other API commands according to the "Veeam Backup RESTful API" - document page 172 - "(POST) /jobs/{ID}/includes".
according to this page the only required elements with a minimum occurrence of 1 are the 'HierarchyObjRef' and the 'HierarchyObjName' elements

I then gathered the VM information and Job information from the rest api and the results are as follows:

JOB INFO:
Code: Select all
<EntityRef Href="http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9" Type="JobReference" UID="urn:veeam:Job:fbf4d541-f72f-4f40-9d5a-87d2df1521f9" Name="opt-test-bkp"
    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">
    <Links>
        <Link Href="http://{{server}}:9399/api/backupServers/ef17bbdf-ac22-4936-9c60-d6c59cd871cb" Name="{{server}}" Type="BackupServerReference" Rel="Up"/>
        <Link Href="http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9?format=Entity" Name="opt-test-bkp" Type="Job" Rel="Alternate"/>
        <Link Href="http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/backupSessions" Type="BackupJobSessionReferenceList" Rel="Down"/>
    </Links>
</EntityRef>


VM INFO:
Code: Select all
<HierarchyItems
    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">
    <HierarchyItem Type="HierarchyItem">
        <ObjectRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</ObjectRef>
        <ObjectType>Vm</ObjectType>
        <ObjectName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</ObjectName>
    </HierarchyItem>
</HierarchyItems>


with this information I constructed the following attempts at adding a vm to a job:

1) POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes
Code: Select all
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>


2)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>


3)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes
Code: Select all
<?xml version="1.0" encoding="utf-8"? xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>


4)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes

Code: Select all
<?xml version="1.0" encoding="utf-8"? xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>URN:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>



Here are the resulting Tasks:

Code: Select all
<Tasks
    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">
    <Task Type="Task" Href="http://{{server}}:9399/api/tasks/task-50">
        <Links>
            <Link Href="http://{{server}}:9399/api/tasks/task-50" Type="Task" Rel="Delete"/>
        </Links>
        <TaskId>task-50</TaskId>
        <State>Finished</State>
        <Operation>UpdateJob</Operation>
        <Result Success="false">
            <Message>Object reference not set to an instance of an object.</Message>
        </Result>
    </Task>
    <Task Type="Task" Href="http://{{server}}:9399/api/tasks/task-51">
        <Links>
            <Link Href="http://{{server}}:9399/api/tasks/task-51" Type="Task" Rel="Delete"/>
        </Links>
        <TaskId>task-51</TaskId>
        <State>Finished</State>
        <Operation>UpdateJob</Operation>
        <Result Success="false">
            <Message>Object reference not set to an instance of an object.</Message>
        </Result>
    </Task>
    <Task Type="Task" Href="http://{{server}}:9399/api/tasks/task-52">
        <Links>
            <Link Href="http://{{server}}:9399/api/tasks/task-52" Type="Task" Rel="Delete"/>
        </Links>
        <TaskId>task-52</TaskId>
        <State>Finished</State>
        <Operation>UpdateJob</Operation>
        <Result Success="false">
            <Message>Object reference not set to an instance of an object.</Message>
        </Result>
    </Task>
    <Task Type="Task" Href="http://{{server}}:9399/api/tasks/task-53">
        <Links>
            <Link Href="http://{{server}}:9399/api/tasks/task-53" Type="Task" Rel="Delete"/>
        </Links>
        <TaskId>task-53</TaskId>
        <State>Finished</State>
        <Operation>UpdateJob</Operation>
        <Result Success="false">
            <Message>Object reference not set to an instance of an object.</Message>
        </Result>
    </Task>
</Tasks>


Out of curiosity I exported the logs for the day under the VBR manager and looked at the generated log file titled "Svc.VeeamRestAPI.txt":

inside it I found corresponding logs with the same error message corresponding to a null pointer exception.

I would show you exactly but the forum rules forbid log snippets.
ameyerhoff
Service Provider
 
Posts: 7
Liked: 1 time
Joined: Wed Apr 06, 2016 2:03 pm

Re: add vm to backup job

Veeam Logoby ameyerhoff » Fri May 06, 2016 2:20 am

quick edit the log file is called "Svc.VeeamRestAPI.log"

and

3)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes
CODE: SELECT ALL
Code: Select all
<?xml version="1.0" encoding="utf-8"? xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>

4)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes

CODE: SELECT ALL

Code: Select all
<?xml version="1.0" encoding="utf-8"? xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
            <HierarchyObjRef>URN:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>



should read as

3)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<CreateObjectInJobSpec 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">
            <HierarchyObjRef>urn:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>


4)POST: http://{{server}}:9399/api/jobs/fbf4d541-f72f-4f40-9d5a-87d2df1521f9/includes

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<CreateObjectInJobSpec 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">
            <HierarchyObjRef>URN:VMware:Vm:4057279b-3383-41fa-8c39-0b10702cbfb4.vm-11744</HierarchyObjRef>
            <HierarchyObjName>opt-in-out-test (23c65f0e-b1fe-482b-bbe6-a2d6a9c5134a)</HierarchyObjName>
</CreateObjectInJobSpec>
ameyerhoff
Service Provider
 
Posts: 7
Liked: 1 time
Joined: Wed Apr 06, 2016 2:03 pm

Re: add vm to backup job

Veeam Logoby tdewin » Fri May 06, 2016 9:33 am

Seems correct. I checked one of my tests (which works) only to find I specified order. However following the xsd, it has min of 0 so it should not be required. Maybe you can try to add it, and see if it makes a difference.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
 <CreateObjectInJobSpec xmlns="http://www.veeam.com/ent/v1.0">
  <HierarchyObjRef>urn:VMware:Vm:f49942ee-2098-4a6c-af36-be7e1c82458a.vm-14765</HierarchyObjRef>
  <HierarchyObjName>timocbt</HierarchyObjName>
  <Order>1</Order>
 </CreateObjectInJobSpec>


If this doesn't work, could you try a VM without spaces and parenthesis? Might also be worth mentioning this is running an example against v9u1
tdewin
Veeam Software
 
Posts: 1043
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

Re: add vm to backup job

Veeam Logoby ameyerhoff » Fri May 06, 2016 1:23 pm

This worked! The addition of the Order element solved my issue. Thank you for pointing this out. Is there a way that the support documentation can get updated to reflect this? Do I need to put that request in my customer support ticket?
ameyerhoff
Service Provider
 
Posts: 7
Liked: 1 time
Joined: Wed Apr 06, 2016 2:03 pm

Re: add vm to backup job

Veeam Logoby tdewin » Fri May 06, 2016 3:46 pm

Well now it is documented here so that's good, but indeed add a comment to your case and refer to this thread so they can track it.
tdewin
Veeam Software
 
Posts: 1043
Liked: 361 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin


Return to RESTful API



Who is online

Users browsing this forum: No registered users and 2 guests