Reputation: 23
I get an error when I run the following code:
http.post(url,
body: {"access_token": "bfa67f6f8389f421d8ac0106f040d19b40d8a69112402a76b87d66aea86a",
"title": "HelloWorld!",
"content": [{
"tag": "p",
"children":
["Hello world!"]
}
],
"return_content": true
},
I know that dart is complaining because I have an array which contains a map within my map. How can I deal with this?
EDIT: I would normally encode it as JSON but the API only accepts strings
Upvotes: 1
Views: 132
Reputation: 71723
The body
argument must have type String
, and it doesn't.
Your value looks like a JSON-like structure, so you probably want to encode that object structure as a String using the json
encoder:
import "dart:convert";
...
var body = jsonEncode({"access_token": "..... " ... });
http.post(url, body: body);
Upvotes: 2