RESTful knowledge exchange
Post Reply
twesterd
Influencer
Posts: 17
Liked: 3 times
Joined: May 17, 2017 7:38 pm
Full Name: Trevor W
Contact:

Cant Get Task Status of Clone

Post by twesterd »

I can successfully post a a request to clone a job (and the clone is actually created); however, instead of returning "completed", the response indicates "Accepted" and the task is "running". I expect this because the documentation for cloning shows I should get a Task back:

https://helpcenter.veeam.com/docs/backu ... tml?ver=95

Here is the type of XML returned:
<?xml version="1.0" encoding="utf-8"?><Task Href="https://veeamserver.local:9398/api/tasks/task-1" Type="Task" 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="https://veeamserver.local:9398/api/tasks/task-1" Rel="Delete"/></Links><TaskId>task-1</TaskId><State>Running</State><Operation>CloneJob</Operation></Task>

The link above indicates I need to use the following URL to get the status for the clone job back:

https://veeamserver:9398/api/tasks/{task-id}

The XML response from the clone job does have a task ID (I.e. task-1). However, when I try to get the status, I get this response from my request:

<?xml version="1.0" encoding="utf-8"?><Error Message="There is no backup task with id [task-1] in current rest session" StatusCode="500" xmlns="http://www.veeam.com/ent/v1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan ... sage>There is no backup task with id [task-1] in current rest session</FirstChanceExceptionMessage><StackTrace>Veeam.Backup.Interaction.RestAPI.CRestAPICommunicationException: There is no backup task with id [task-1] in current rest session ---> System.Exception: There is no backup task with id [task-1] in current rest session&#xD;
at Veeam.Backup.Enterprise.RestAPIService.CRestApiBackupTasksScope.GetTask(CTaskUid taskId)&#xD;
at Veeam.Backup.Enterprise.RestAPIService.CEnterpriseRestServiceStub.GetTask(String taskIdStr)&#xD;
at SyncInvokeGetTask(Object , Object[] , Object[] )&#xD;
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)&#xD;
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)&#xD;
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)&#xD;
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)&#xD;
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)&#xD;
--- End of inner exception stack trace ---</StackTrace></Error>

I am using the same session and I don't get it.

How do I get the status of a clone job? It appears like that the URL should be used for backup jobs (based on the message within the XML) and perhaps that URL is not for clone jobs???

Again, how to I get the clone job's status?
benyoung
Veeam Vanguard
Posts: 148
Liked: 47 times
Joined: May 25, 2016 3:29 am
Full Name: Ben Young
Contact:

Re: Cant Get Task Status of Clone

Post by benyoung »

We use the clone quite heavily and i have not come across that before. The only time i have seen that is when you switch sessions/query that task with a different sessionid - could be environmental? What version are you running?
If you initiate something else that generates a taskid are you able to get those? Assuming not?

I have just tested on my development server

POST To:

http://devbackupserver:9399/api/jobs/cd ... tion=clone

Payload:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<JobCloneSpec 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">
 <BackupJobCloneInfo>
   <JobName>FileServers Backup Cloned</JobName>
   <FolderName>Cloned Job</FolderName>
   <RepositoryUid>urn:veeam:Repository:d959d006-b863-45c8-8a84-1b81776bac4a</RepositoryUid>
 </BackupJobCloneInfo>
</JobCloneSpec>
Reponse:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Task Href="http://devbackupserver:9399/api/tasks/task-25" Type="Task" 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://devbackupserver:9399/api/tasks/task-25" Rel="Delete"/>
    </Links>
    <TaskId>task-25</TaskId>
    <State>Running</State>
    <Operation>CloneJob</Operation>
</Task>
GET to:

http://devbackupserver:9399/api/tasks/task-25

Response:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Task Href="http://devbackupserver:9399/api/tasks/task-25" Type="Task" 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://devbackupserver:9399/api/tasks/task-25" Rel="Delete"/>
        <Link Href="http://devbackupserver:9399/api/jobs/e3016290-c5e9-4320-8a45-c6a4275f6f2f?format=Entity" Name="FileServers Backup Cloned" Type="Job" Rel="Related"/>
    </Links>
    <TaskId>task-25</TaskId>
    <State>Finished</State>
    <Operation>CloneJob</Operation>
    <Result Success="true">
        <Message>Ok</Message>
    </Result>
</Task>
twesterd
Influencer
Posts: 17
Liked: 3 times
Joined: May 17, 2017 7:38 pm
Full Name: Trevor W
Contact:

Re: Cant Get Task Status of Clone

Post by twesterd »

I am using version 9.5.0.823 of Veeam.

I will add some debugging output to include the session ID so I can confirm my code is somehow NOT generating new ones and will respond back shortly.
twesterd
Influencer
Posts: 17
Liked: 3 times
Joined: May 17, 2017 7:38 pm
Full Name: Trevor W
Contact:

Re: Cant Get Task Status of Clone

Post by twesterd »

Okay, you sent me on the right path. I am using RestSharp and .NET code to access the API and I have a class that gets the session ID and keeps using it for requests.... but... in my test code, I was creating a new instance of the class which essentially guaranteed my request to clone and my request for task status were using two different session IDs. Changed the scope of the class where it should be and it works fine now.

Thanks!
benyoung
Veeam Vanguard
Posts: 148
Liked: 47 times
Joined: May 25, 2016 3:29 am
Full Name: Ben Young
Contact:

Re: Cant Get Task Status of Clone

Post by benyoung »

All good - I really wish that the design of this would be changed especially for what we do with the API.

Would be ideal if tasks were a global thing, by default standard users would only have access to their own tasks etc but as an admin you could access any
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests