I'm trying to send an API request to the DeepApi Toonify website using flutter but I'm having some issues as I do not understand how to go about doing it.

This is how the toonify API request should look like

curl \
-F 'image=YOUR_IMAGE_URL' \
-H 'api-key:quickstart-QUdJIGlzIGNvbWluZy4uLi4K' \

This is what I have right now.

var dioRequest = new Dio();

FormData formData = FormData.fromMap({
  "file": await MultipartFile.fromFile(pickedFile.path,filename: pickedFile.path.split('/').last)

var response = await dioRequest.post(
  data: formData,
  options: Options(
    headers: {
      'api-key': 'MY API KEY'

What am I doing wrong?

Solution 1: Ace

i found a solution that worked for me. Here's the correct way of Sending an Authenticated API Request with a file.

var request = http.MultipartRequest("POST", Uri.parse("<URL>"));
//add Headers
request.headers['Api-Key'] = 'Your API key';
//create multipart using filepath, string or bytes
var pic = await http.MultipartFile.fromPath("image", file.path);

//add multipart to request
var response = await request.send();
var responseData = await response.stream.toBytes();
var responseString = String.fromCharCodes(responseData);