Dio: '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

Created on 18 Jun 2018  路  5Comments  路  Source: flutterchina/dio

So I am getting this Error on my data which is a Map. The request still completes (data changes on the server but can't get rid of this error) my code:

 Dio dio = new Dio();
  try {
    Response response = await dio.put(
      Uri.encodeFull(api+"/api/v1/auth/me/"), 
      options: new Options(headers: {
        "Authorization": "Token $token",
        "Content-Type": "application/json",
      }, 
      data: {
        "last_name": user.firstName,
        "first_name": user.lastName,
        "telephone": telephone,
        "send_notices": reminders.toString(),
      },
    ));

    if (response.statusCode != 400) {
      var data = json.decode(response.data);
      print(data);
      return true;
    }
  } catch (e) {
    print("Error updating UserInfo: $e");
  }

  return false;
}

Most helpful comment

I also encountered this problem, the response.data['name'] has been decoded, you can use it directly, the same problem here at https://github.com/flutterchina/dio/issues/3

All 5 comments

I also encountered this problem, the response.data['name'] has been decoded, you can use it directly, the same problem here at https://github.com/flutterchina/dio/issues/3

Ahh I see. I thought the problem was with the data in the body of the request not the response. Thank you again for point this out. :) all works now 馃憤

it's still happen when get with response is json like this:

{
    "message": "Please login first !"
}

(statusCode 401)
i checked with Postman !

@lyquocnam error.response.data["message "]

:octocat: From gitme Android

I had

Response<String> response = await dio.get(url.toString());

which I copied from README.md. But Response works better without specific type.

Response response = await dio.get(url.toString());
Was this page helpful?
0 / 5 - 0 ratings