`project_id_missing` in Cloud Function when trying to create a file
- 0
- 2
- Self Hosted
- Functions
- Storage
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.
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:
var fileBytes = await Storage(client).getFileDownload(
bucketId: importDataBucketId,
fileId: fileId,
);
then I get this error:
AppwriteException: project_id_missing, When using project API key, make sure to pass x-appwrite-project header with your project ID. (403)
Looks like I had to add to the client ..addHeader('X-Appwrite-Project', Platform.environment['APPWRITE_FUNCTION_PROJECT_ID'] as String).
found the issue - https://github.com/appwrite/sdk-generator/pull/1732
will release it soon
Great thanks!
its been fixed with 26.2.0
Recommended threads
- Unable to init function via cli
Hello! I have created a new self hosted instance of appwrite 1.9.6 and have connected to that insatnce with the cli 27.2.0 that was released a few hours ago. Wh...
- Appwrite-injected variables are not avai...
I am using rust-1.83 as a runtime and try to access APPWRITE_FUNCTION_API_ENDPOINT or APPWRITE_FUNCTION_API_KEY during runtime. Both are not set during my execu...
- OAuth Missing redirect URL
Hello all, on a Flutter mobile app with latest Appwrite dependency (25.4.0) I always got "Missing redirect URL" - "Your OAuth login flow is missing a proper red...