`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!
Recommended threads
- New OAuth provider not appearing in Cons...
Hi team! I'm contributing to Appwrite and currently working on adding Hugging Face as a new OAuth provider. Here's what I've done so far: - Implemented the ...
- Can Appwrite logs be output without bein...
Hi, I'm trying to use the Better Stack Collector to forward my Appwrite logs to Better Stack. The issue is that Appwrite seems to format the logs for terminal ...
- Static site not being served
Hey everyone, I’m having an issue deploying a Vue/Vite app through self hosted Appwrite Sites and could use some help. Setup: * Appwrite is self-hosted with T...