kokoko
kokoko

Reputation: 3964

flutter http send empty body

this is what i tried:

Future<User> guestLogin(String deviceID) async {
  var body = {
    "deviceid": deviceID,
  };

  var bodyEncoded = json.encode(body);

  Response response = await client.post(
    "$_baseURL/api/user/guest",
    body: bodyEncoded,
    headers: {"Content-Type": "application/json"},
  );
  return User.fromJson(json.decode(response.body));
} 

but when i check it from serverside which coded by golang then i see that the body is empty. when i try it on postman its working well. Where is the problem?

Upvotes: 0

Views: 170

Answers (1)

nowo
nowo

Reputation: 26

try jsonEncode(body) instead of json.encode(body)

Upvotes: 1

Related Questions