Back

[SOLVED] URL in Create team membership in Server (Bun) sdk

  • 0
  • Teams
Mosh Ontong
22 Nov, 2023, 18:06

Based on this documentation: https://appwrite.io/docs/references/cloud/server-nodejs/teams#createMembership

It indicates or labeled the url is an optional parameter. However in the sdk have this createMembership(teamId: string, roles: string[], url: string, email?: string, userId?: string, phone?: string, name?: string): Promise<Models.Membership>;

As you can see the urlparameter is not optional. I am creating a membership through Server sdk. I think that no need to pass a url parameter? since it automatically add the member right?

TL;DR
The user was encountering an issue with the URL parameter in the createMembership function in the Server (Bun) SDK. They were getting a required parameter error even though the documentation stated that the URL parameter is optional. The user realized they forgot to update their Appwrite version and thought it was causing the issue. They later discovered that the URL parameter is indeed required in the server SDK. The user believes it should be optional since the server should automatically add the member. Solution: The user needs to pass a valid URL parameter when using the server SDK's createMembership function.
Mosh Ontong
22 Nov, 2023, 18:12

await teams.createMembership($id, ["owner"], "", undefined, ownerRef);

as you can see I just left empty string in url passing values. But the error message said:

Error creating team: Invalid url param: URL host must be one of: localhost, cloud.appwrite.io

ideclon
22 Nov, 2023, 18:19

I believe the URL is optional in a mobile app - the SDK will automatically handle redirecting back to the app.

Mosh Ontong
22 Nov, 2023, 18:20

I think this is consider as a bug on server sdk?

ideclon
22 Nov, 2023, 18:21

No, why?

Mosh Ontong
22 Nov, 2023, 18:22

url parameter in server sdk is required😩

Mosh Ontong
22 Nov, 2023, 18:22

the documentation said that the url parameter should be an optional

ideclon
22 Nov, 2023, 18:24

It's optional for mobile. If you're not on mobile, you'll need to set a redirect URL - how would Appwrite know where to send the user, otherwise?

Mosh Ontong
22 Nov, 2023, 18:32

As I said earlier, The documentation tells that in server sdk it automatically added the user in team

Mosh Ontong
22 Nov, 2023, 18:32

other one

Mosh Ontong
22 Nov, 2023, 18:33
Mosh Ontong
22 Nov, 2023, 18:33

as you can see the URL does not have required label so I think the Server sdk should also do the optional parameter

Mosh Ontong
22 Nov, 2023, 18:34

Url, become useless if the server side will auto added the member. Hence, there is no need to pass a url

ideclon
22 Nov, 2023, 19:08

Wait, I see what you're saying, sorry. I just checked the SDK, and as far as I can tell, url is an optional parameter in the server SDKs - https://github.com/appwrite/sdk-for-node/blob/3e4e6ce7b1227be7ba7938b188a37df63cc24e4c/index.d.ts#L4120

Mosh Ontong
23 Nov, 2023, 01:57

why I am getting a required parameter

Mosh Ontong
23 Nov, 2023, 01:58

ohh I see I forgot to update the appwrite version, I thought was the bun template using the latest version of appwrite

Mosh Ontong
23 Nov, 2023, 01:58

thanks for the help

ideclon
23 Nov, 2023, 02:41

If your issue has been solved, you can close this post by adding β€œ[SOLVED]” to the beginning of the title

Mosh Ontong
23 Nov, 2023, 05:04

[SOLVED] URL in Create team membership in Server (Bun) sdk

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