Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Listing user tasks through REST API doesnt always work

Mariana Aires August 18, 2020

We're building on our front page a list of tasks for each user. For this effect, we use AJAX to call the REST API:

jQuery.ajax({
url: "/rest/mywork/1/task",
type: "GET",
dataType: "json",
success: function(data){ }

While this works, it doesn't show all the user tasks, only some of them. When I print the results, not all the user tasks are shown. Is there an way I can force it to show all the tasks?

1 answer

1 vote
Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 18, 2020

Hi @@Mariana Aires 

REST API responses in Confluence server are, most of the times, paginated as highlighted in Pagination in the REST API .

You may want to play with the following REST API call, which is the same used for the Task Report that is found in the user's profile.

/rest/inlinetasks/1/my-task-report/?pageSize=5&pageIndex=0&reportParameters=%7B%22columns%22%3A%5B%22description%22%2C%22duedate%22%2C%22location%22%5D%2C%22assignees%22%3A%5B%22user001%22%5D%2C%22creators%22%3A%5Bnull%5D%2C%22status%22%3A%22incomplete%22%2C%22sortColumn%22%3A%22duedate%22%2C%22reverseSort%22%3Afalse%7D

 

You may change the pageSize and pageIndex values to get different results.

pageSize: how many tasks in the current page

pageIndex: which page to get, starting from 0

 

I hope that helps.

Kind regards,
Thiago Masutti

Mariana Aires August 19, 2020

When I try using the call you suggested, this is the result I get

{currentPage: 0, totalPages: 0, adaptive: false, detailLines: Array(0)}

Changing the parameters doesn't fix it. 

Thiago Masutti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2020

Hi @Mariana Aires 

I forgot to give you an additional information on that URL.

Where you read user001, change it for the target username.

That should do it.

Kind regards,
Thiago Masutti

Mariana Aires August 21, 2020

Is there a way to assign it to the current user?

David
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 6, 2022

Hi @Thiago Masutti ,

I also need the API to read task and your solution it works for me. Thank you. 

Is there any API document or introduction of this?

rest/inlinetasks/1/my-task-report/

I want to know more detail. 

Thank you.  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events