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
- Function's Static IP
Is it possible to have static. IP Address instead of Dynamic IP for getting the IP Address whitelist
- How to use dart workspaces to deploy a f...
Hello, I'm developing a Flutter application and I would like to leverage dart pub workspaces to deploy a function with a dart runtime as advertised here : http...
- [SOLVED] Unable to push function from AP...
When trying to push functions from Gitlab CI (with an API KEY and using the CLI), i saw that i was unable to push functions. ``` $ appwrite client --endpoint $...