REST API knowledge exchange
Post Reply
paulmcnally
Service Provider
Posts: 14
Liked: never
Joined: Feb 26, 2020 10:19 am
Full Name: Paul McNally
Contact:

GET /api/tasks not showing any tasks

Post by paulmcnally »

Hi, I'm trying to retrieve a task from the API.

I've performed a PUT on a tenant and the response is a task that was created:

Code: Select all

stdClass Object
(
    [TaskId] => task-6
    [State] => Running
    [Operation] => EditCloudTenant
    [Result] => 
    [Links] => Array
        (
            [0] => stdClass Object
                (
                    [Rel] => Delete
                    [Href] => https://localhost:9398/api/tasks/task-6
                    [Name] => 
                    [Type] => 
                )

        )

    [Href] => https://localhost:9398/api/tasks/task-6
    [Type] => Task
)

But Querying

Code: Select all

https://localhost:9398/api/tasks
returns an empty set

Code: Select all

{#315 ▼
  +"Tasks": []
}
Or even if I query the task Href directly from the response

Code: Select all

https://localhost:9398/api/tasks/task-6

Code: Select all

{"FirstChanceExceptionMessage":null,"StackTrace":null,"Message":"There is no backup task with id [task-6] in current rest session","StatusCode":500,"Status":"InternalServerError"}

I have even tried using /query

Code: Select all

https://localhost:9398/api/query?type=Task
gives me an empty result set

Code: Select all

{#315 ▼
  +"Tasks": []
}
Any suggestions?

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

Re: GET /api/tasks not showing any tasks

Post by benyoung »

Hey Paul

Are you using the same session (X-RestSvcSessionId) that initiated the task?

If i recall correctly Tasks can only be fetched by the session that created by them, i ran across this when building a web based file level restore we had to cache the sessionid per restore session/user in order to make this work. This was a few years ago now though.

Thanks

Ben
paulmcnally
Service Provider
Posts: 14
Liked: never
Joined: Feb 26, 2020 10:19 am
Full Name: Paul McNally
Contact:

Re: GET /api/tasks not showing any tasks

Post by paulmcnally »

Are you using the same session (X-RestSvcSessionId) that initiated the task?
Hi Ben, no I wasn't, will give that a try. Thanks
veremin
Product Manager
Posts: 20400
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: GET /api/tasks not showing any tasks

Post by veremin »

Ben is correct, you need to operate within the same session to get the task and its state.

The task example is provided here. Check EditCloudTenant one.

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests