Skip to content
Back

`project_id_missing` in Cloud Function when trying to create a file

  • 0
  • 2
  • Self Hosted
  • Functions
  • Storage
4 Aug, 2026, 17:07

I've got a cloud function written in Dart-3.12 that I'm trying to create a file in a file bucket. I'm using the latest dart_appwrite sdk (26.1.0) and Appwrite 1.9.5 on a local selfhosted instance. I'm using http://host.docker.internal/v1 as the endpoint inside of the function. I've tried using the dynamic api key generated for the function as well as a manually created api key (that is saved in an env var), and both have the issue even though they have all scopes. Below is where I'm creating the client that is then fed into the Storage(client) object for saving the file in a bucket.

TypeScript
final client = Client()
        ..setEndpoint(injectedEndpoint.contains('localhost') ? 'http://host.docker.internal/v1' : injectedEndpoint)
        ..setProject(Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] as String)
        ..setKey(context.req.headers['x-appwrite-key'] ?? context.req.headers['X-Appwrite-Key']);

Again, I've logged exactly what is being saved for each of those and the expected values are used. Whenever I do:

TypeScript
var fileBytes = await Storage(client).getFileDownload(
      bucketId: importDataBucketId,
      fileId: fileId,
    );

then I get this error:

TypeScript
AppwriteException: project_id_missing, When using project API key, make sure to pass x-appwrite-project header with your project ID. (403)
TL;DR
Cloud Function encountering `project_id_missing` error when attempting to create a file in a file bucket using the latest `dart_appwrite` SDK. Client needs `..addHeader('X-Appwrite-Project', Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] as String)` added to resolve the issue. A fix is pending in an upcoming release.
4 Aug, 2026, 17:25

Looks like I had to add to the client ..addHeader('X-Appwrite-Project', Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] as String).

4 Aug, 2026, 17:29

will release it soon

4 Aug, 2026, 17:30

yeah it should have been added by the sdk

1
4 Aug, 2026, 17:31

Great thanks!

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