Getting a 403 from response.status_code when trying to make a request from the API with requests.get

Hey there everyone,

I need help with an error that i’m getting from trying to make a request.get to get the tasks of a project from the API Asana.
please find the code sample below.
Thank you for your help in advance

import asana
import requests
import json
import pandas as pd

asana_api_key = “{personal_Asana_Token}”
headers = {“Authorization”: f"Bearer {asana_api_key}"}
client = asana.Client.access_token(asana_api_key)
me = client.users.me()
print(me)

project_id = {project_Id}
response = requests.get(f"Log in - Asana", headers=headers, params=“value”)
tasks = response.json()[“data”]

hi Adiba it’s me :wave:

I realised your endpoint might be wrong.
If you look at the doc: Get tasks from a project

The endpoint is https://app.asana.com/api/1.0/projects/{project_gid}/tasks, it looks like you are missing the /projects isn’t it?

2 Likes

and also missing the /api/1.0

1 Like

Hello Bastien,

So after your answer and looking at the documentation I figured that i was targeting the wrong endpoint.
After changing it based on what you said it worked just fine.

Thank you very much for your help :smile:

1 Like