Home > other >  Patch request in flutter/dart
Patch request in flutter/dart

Time:02-08

I am trying to make a patch request in flutter and in the body I write my values as:

body: {
"var" : [v]
}

But I keep getting this error:

Unhandled Exception: Bad state: Cannot set the body fields of a Request with content-type "application/json".

CodePudding user response:

You need to convert your data to JSON using json.encode:

import 'dart:convert';

body: json.encode({"var" : [v]});
  •  Tags:  
  • Related