# Getting task details results in ForbiddenError

**URL:** <https://forum.asana.com/t/getting-task-details-results-in-forbiddenerror/137310>\
**Category:** API & Developers\
**Created:** [27 September 2021 15:08 UTC](https://forum.asana.com/t/getting-task-details-results-in-forbiddenerror/137310 "2021-09-27T15:08:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Saari](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/robert_saari/32/56428_2.png) [@Robert\_Saari](https://forum.asana.com/u/Robert_Saari)\
**Post date:** [27 September 2021 15:08 UTC](https://forum.asana.com/t/getting-task-details-results-in-forbiddenerror/137310/1 "2021-09-27T15:08:42Z")

</div>

I’m using the Python Asana client library to retrieve task details. The API call I’m making is client.tasks.get\_task(task\_gid). As the code loops through a list of tasks and retrieves the task details it dumps the results into a database. Everything works fine (albeit slow), until it gets to a private(?) task, which then causes the script to fail with the error message _“asana.error.ForbiddenError: Forbidden: You do not have access to this task.”_

In my error handling, I have tried to handle this as follows:

```auto
try:
    do stuff here
except KeyError:
        pass
except asana.error.ForbiddenError:
        print("This task failed to insert: " + str(detail['gid']))
        continue

```

Unfortunately, this does not resolve the issue and the script continues to fail with the same error. How can I handle the ForbiddenError response?

---

<div class="post-metadata">

**Author:** ![ShunS](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/shuns/32/115053_2.png) [@ShunS](https://forum.asana.com/u/ShunS)\
**Post date:** [28 February 2022 18:14 UTC](https://forum.asana.com/t/getting-task-details-results-in-forbiddenerror/137310/2 "2022-02-28T18:14:32Z")

</div>

Hi @Robert_Saari ,

I’m sorry for the very late response.  
I tried to fetch a private project (which gives “_asana.error.ForbiddenError: Forbidden: You do not have access to this project._”) and the error was handled correctly for me 🤔

 ![Screen Shot 2022-03-01 at 3.15.50](https://us1.discourse-cdn.com/asana/original/3X/c/e/ceed3e1cfa07d20f82f17cd36ffa94c811733dd4.png)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:04 UTC](https://forum.asana.com/t/getting-task-details-results-in-forbiddenerror/137310/3 "2025-05-30T19:04:33Z")

</div>

Closed on 30 May 2025 19:04 UTC


