Search code examples
jsonflutterapidartpost

I get the error 'Unhandled Exception: Converting object to an encodable object failed: Null' in flutter


I am trying to post a JSON to our api but keep getting this error even if all values are NULL and are allowed to be NULL, here is the code snippet that causes the issue.

   final response = await http.post(Uri.parse('http://"api"/api/createPin'),
    body: json.encode({

      'location': Null,
      'description': Null,
      'qrcode': Null,
      'ttl': Null,
      'tier': Null,
      'type': Null,
      'user': Null,
      'images': Null,
      'viewable_users': Null
    }),
    );

ive searched forums and also a few videos but none solved my problem and I do not know what im doing wrong.


Solution

  • How about changing from Null to null?