8000 GitHub Β· Where software is built
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
πŸ› Bug Report: Invalid JSON when there is no body pass in parameter Dart cloud functionΒ #7267
Closed
@moshOntong-IT

Description

@moshOntong-IT

πŸ‘Ÿ Reproduction steps

 @override
  Future<VideoToken> token({required String room}) async {
    try {
      final Execution(:responseBody, :responseStatusCode) =
          await functions.functions.createExecution(
        functionId: functions.videoFunctionId,
        method: 'POST',
        headers: {
          'content-type': 'application/json',
          'room': room,
        },
        xasync: false,
        path: '/v1/token',
      );

      final body = jsonDecode(responseBody) as Map<String, dynamic>;

      if (responseStatusCode == 200) {
        _logger.info('Token created');
        return VideoToken.fromJson(body);
      } else {
        _logger.severe(
          (body['message'] as String?) ?? 'Failed to create token',
        );
        throw VideoTokenException(
          (body['message'] as String?) ?? 'Failed to create token',
          StackTrace.current,
        );
      }
    } on AppwriteException catch (e, stackTrace) {
      _logger.severe(e.message, e, stackTrace);
      throw VideoTokenException(e.message ?? 'Failed to get token', stackTrace);
    } catch (e, stackTrace) {
      _logger.severe(e, e, stackTrace);
      throw VideoTokenException(e.toString(), stackTrace);
    }
  }

As you can see there is no body pass in the parameter of createExecution, if I run this this is the error:

image

πŸ‘ Expected behavior

It should execute the function without body

πŸ‘Ž Actual Behavior

It gives me Invalid JSON, but If I pas a value on body parameter it execute successfully

🎲 Appwrite version

Appwrite Cloud

πŸ’» Operating system

Windows

🧱 Your Environment

No response

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏒 Have you read the Code of Conduct?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0