#403 Forbidden error when fetching data from collections using API token

2 messages · Page 1 of 1 (latest)

lyric mantle
#

Hi,

I am encountering an issue when trying to fetch data from my Definitionl and Definitionc collections using the Directus API.
I have an API token with read access to these collections, but when I make requests to the following endpoints: http://0.0.0.0:8055/items/Definitionl and http://0.0.0.0:8055/items/Definitionc, I receive a 403 Forbidden error with the message "You don't have permission to access this." Here is the code I am using for making requests:
async function fetcher(url) { const response = await fetch(url, { headers: { 'Authorization': process.env.NEXT_PUBLIC_API_TOKEN, }, }); const data = await response.json(); return data.data; }“

I have double-checked the API URL and token, and they appear to be correct. I can successfully fetch data from other collections such as Categorie and Concept using the same method. I have also tried accessing the endpoints using Postman with the same API token, but I still get the 403 Forbidden error.

I have reviewed the Directus logs, but I have not found any additional information that could help me understand the cause of the issue. My API token has the necessary read permissions for the Definitionl and Definitionc collections, so I am not sure why I am still encountering this error.

Could anyone please help me understand what might be causing this issue and how to resolve it? Any assistance would be greatly appreciated.

Thank you in advance!

wraith knotBOT
#

Thanks for posting! This is a community powered server, so you may or may not get an answer based on available help and expertise. To increase your chances of somebody being able to help you, please help us help you making sure you:

  • Adding an explanation of exactly what you're trying to achieve.
  • Adding any and all related code or previous attempts.
  • Describing the exact issue or error you are facing.
  • Posting any screenshots if applicable.
  • Reading through https://stackoverflow.com/help/how-to-ask.

When you're done with this thread, please close it. Thanks! ✨

(If you have a support agreement and need help, please contact the core team via email.)