1

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}
        );

1 Answer 1

6

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),
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.