Back

HTTP POST to function returning "No Appwrite project was specified"

  • 0
  • Self Hosted
  • Functions
MightyMoppes
9 Dec, 2024, 21:09

Hi everyone,

I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNCTION_API_ENDPOINT, etc.), and I’ve also hardcoded values directly into the function code for testing. I am using the starter function, by the way. I did not modify it, yet.

When I execute the function from the Appwrite Console, everything works perfectly—no errors at all. However, when I try to call the function via an external HTTP POST request, I get the following response:

{ "message": "No Appwrite project was specified. Please specify your project ID when initializing your Appwrite SDK.", "code": 401, "type": "general_access_forbidden", "version": "1.6.0" }

What I’ve tried so far: Double-checked that APPWRITE_FUNCTION_PROJECT_ID is set correctly in the function settings. Directly hardcoded the APPWRITE_FUNCTION_PROJECT_ID and API endpoint into the function code for testing. Verified that the Appwrite SDK client is initialized with the correct project ID, API endpoint, and API key:

const client = new Client() .setEndpoint('https://my-instance/v1') // My Appwrite API endpoint .setProject('my-project-id') // My project ID .setKey('my-api-key'); // My API key

Made sure the API key has the correct scopes (execution.read and execution.write).

The HTTP POST request includes the following headers: x-appwrite-key: My valid API key content-type: application/json

The function is set to the role "Any" to allow execution by anyone.

The issue only happens with external HTTP POST requests. Console-based execution works fine. I’m using Appwrite version 1.6.0.

Has anyone faced this issue or knows what could be causing this? I’d appreciate any guidance on how to debug or resolve this problem.

Thanks in advance!

TL;DR
Developers having issue calling Appwrite function via external HTTP POST request receive "No Appwrite project was specified" error message. Possible solutions: 1. Ensure APPWRITE_FUNCTION_PROJECT_ID environment variable is correctly set. 2. Check that Appwrite SDK client is initialized with correct project ID, API endpoint, and key. 3. Confirm API key has required scopes (execution.read and execution.write). 4. Verify headers in HTTP POST request include x-appwrite-key and content-type. Issue might be related to external HTTP POST requests only.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more