Home > Mobile >  I get the error 'Unhandled Exception: Converting object to an encodable object failed: Null
I get the error 'Unhandled Exception: Converting object to an encodable object failed: Null

Time:01-24

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.

CodePudding user response:

How about changing from Null to null?

CodePudding user response:

You are looking for 'null' and not 'Null'.

Null is a class which cannot be instantiated and null a value.

  • Related