Reputation: 106
I am trying to send a form data to a server and it is returning this error back : Error Message: DioError [DioErrorType.response]: Http status error [422]
How do I solve this issue?
Map<String, String> sentData = {
'firstname': data['first_name'].trim(),
'lastname': data['last_name'].trim(),
'email': data['email'].trim(),
'phone': data['phone'].trim(),
'password': data['password'],
'password_confirmation': data['password_confirmation'],
'country_id': id.toString(),
};
debugPrint('AuthControllerData : Data to Send to Server = $sentData');
final formData = dio.FormData.fromMap(sentData);
var response = await client.HttpClient(resource: 'auth/register').post(data: formData);
debugPrint('AuthController response: $response');
Is this the right way to send the FormData
and are there better way like the options I have to set while using the Dio package to send formdata?
Upvotes: 0
Views: 365