i am trying to use a createMembership in a function like this:
await teams.createMembership(mobiles.documents[0].teamid, ['mobile']);
but it always shows me an error:
Error: Missing required parameter: "url"
at Teams.createMembership (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/teams.js:243:19)
at Module.default (file:///usr/local/server/src/function/src/main.js:28:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async execute (/usr/local/server/src/server.js:141:22)
at async /usr/local/server/src/server.js:158:13
the docu shows that only teamid and role are required: https://appwrite.io/docs/references/1.4.x/server-nodejs/teams#createMembership
edit: i also tried it this way:
await teams.createMembership(mobiles.documents[0].teamid, ['mobile'], 'test@test.at', userId, '', 'localhost' );
but then i get this:
Error: Invalid `email` param: Value must be a valid email address
at Client.call (/usr/local/server/src/function/node_modules/node-appwrite/lib/client.js:172:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Teams.createMembership (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/teams.js:271:16)
at async Module.default (file:///usr/local/server/src/function/src/main.js:28:5)
at async execute (/usr/local/server/src/server.js:141:22)
at async /usr/local/server/src/server.js:158:13
await teams.createMembership(mobiles.documents[0].teamid, ['mobile'], userId, null, null, 'localhost' );
i also tried this now and get this:
Error: Invalid `phone` param: Phone number must start with a '+' can have a maximum of fifteen digits.
at Client.call (/usr/local/server/src/function/node_modules/node-appwrite/lib/client.js:172:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Teams.createMembership (/usr/local/server/src/function/node_modules/node-appwrite/lib/services/teams.js:271:16)
at async Module.default (file:///usr/local/server/src/function/src/main.js:28:5)
at async execute (/usr/local/server/src/server.js:141:22)
at async /usr/local/server/src/server.js:158:13
Are you using the client SDK or server SDK?
On the server SDK, URL is optional, but its required on the client SDK
The snippet you shared is the correct usage
await teams.createMembership(teamid, roles, email);
This should work in theory.
hey @Christy Jacob 🙂 thanks for your answer i started with the starter-template 😉
import { Client, Databases, Users, Teams, Query, ID } from 'node-appwrite';
export default async ({ req, res, log, error }) => {
const client = new Client()
.setEndpoint(process.env.ENDPOINT)
.setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
.setKey(process.env.API_KEY);
[Error] Message: {closure}(): Argument #3 ($userId) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 508
[Error] File: /usr/src/code/app/controllers/api/teams.php
[Error] Line: 391
[Error] Timestamp: 2023-10-26T16:01:18+00:00
[Error] Method: POST
[Error] URL: /v1/teams/:teamId/memberships
[Error] Type: Utopia\Exception
[Error] Message: Invalid `phone` param: Phone number must start with a '+' can have a maximum of fifteen digits.
[Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
[Error] Line: 742
[Error] Timestamp: 2023-10-26T16:02:29+00:00
[Error] Method: POST
[Error] URL: /v1/teams/:teamId/memberships
[Error] Type: Appwrite\Extend\Exception
[Error] Message: Given email and phone doesn't match
[Error] File: /usr/src/code/app/controllers/api/teams.php
[Error] Line: 435
this is all very strange, it shows me to fill the phone, then its wrong when i leave it empty, but on my users it is empty
null seems to be wrong
i dont understand it whats going on 😅
[Error] Timestamp: 2023-10-26T16:12:02+00:00
[Error] Method: POST
[Error] URL: /v1/teams/:teamId/memberships
[Error] Type: Utopia\Exception
[Error] Message: Invalid `email` param: Value must be a valid email address
[Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
[Error] Line: 742
what version of the sdk do you have?
Node-appwrite 11.0.0
so you're passing userId for email
No i passed nothing and tried to add the userid of my existing user 😉
But meanwhile a tried a lot of combinations and i am very confused already 😜
@Steven in my opinion this should work, but it leeds to
await teams.createMembership(mobiles.documents[0].teamid, ['mobile'], null, userId, null, 'http://localhost' );
[Error] Timestamp: 2023-10-26T16:14:17+00:00
[Error] Method: POST
[Error] URL: /v1/teams/:teamId/memberships
[Error] Type: Utopia\Exception
[Error] Message: Invalid `email` param: Value must be a valid email address
[Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php
[Error] Line: 742
can you try passing undefined instead of null?
lol thanks that worked.. debugging for hours for that 😂
[SOLVED] createMemberships in functions
Recommended threads
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...
- Function in Node.JS to monitor events ar...
Hello everyone. I'm creating my first Node.JS function, but I don't have much experience with node and javascript. I'm trying to create a function, that monito...