Back

membershipId parameter is missing when creating a team membership in a dart client

  • 0
  • Teams
Arrow
23 Feb, 2024, 19:33

I am using the dart sdk client to create team memberships. However, the membershipId parameter is nowhere to be found.

self-hosted appwrite 1.4.12 dart client: dart_appwrite: ^10.1.1

This is the source api code

TypeScript
Future<models.Membership> createMembership(
      {required String teamId,
      required List<String> roles,
      String? email,
      String? userId,
      String? phone,
      String? url,
      String? name}) async {
    final String apiPath =
        '/teams/{teamId}/memberships'.replaceAll('{teamId}', teamId);

    final Map<String, dynamic> apiParams = {
      'email': email,
      'userId': userId,
      'phone': phone,
      'roles': roles,
      'url': url,
      'name': name,
    };

    final Map<String, String> apiHeaders = {
      'content-type': 'application/json',
    };

    final res = await client.call(HttpMethod.post,
        path: apiPath, params: apiParams, headers: apiHeaders);

    return models.Membership.fromMap(res.data);
  }```
TL;DR
Problem: When creating team memberships using the dart SDK client, the membershipId parameter is missing. Solution: The membershipId parameter is typically used to uniquely identify the membership being created. In the provided API code snippet, the parameter is absent from the createMembership function. It needs to be added to the apiParams map with an appropriate value before making the API call to properly create a team membership.
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