Home > OS >  How make a http post with Dio using data raw in flutter?
How make a http post with Dio using data raw in flutter?

Time:10-22

I'm trying to do a dio post request and I need to specify the body as raw-data Post

enter image description here

Response response = await (await init()).post(url, data: {
        "token": token,
        "code": formol}
        );
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

Try to encode it as a Json:

var json =  {
  "code": "xxxxxxxxx",
  "token": "-------------",
}; 
...
Response response = await _dio.post(url,
  options: Options(headers: {
    HttpHeaders.contentTypeHeader: "application/json",
  }),
  data: jsonEncode(json),
);
  • Related