8000 🐛 Bug Report: Invalid JSON when there is no body pass in parameter Dart cloud function · Issue #7267 · appwrite/appwrite · GitHub
[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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
moshOntong-IT opened this issue Dec 10, 2023 · 0 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@moshOntong-IT
Copy link

👟 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant
0