I am having error, kindly help me with this code, new to Flutter here.
When I'm using https://jsonplaceholder.typicode.com/posts
it is working fine, but I am receiving error using my company URL, but when I am using postman to POST the company URL it is working fine, kindly refer to my code and the image below.
Code:
Dio dio = Dio();
Future postData() async{
const String pathUrl = 'https://202.57.135.121:8443/icbs/ATMInterfaceListener/mobileAppRegistration';
//const String pathUrl = 'https://jsonplaceholder.typicode.com/posts';
dynamic data = {
'email': 'darwikf@gkdkkk.com',
'password': 'test123456',
'firstName': 'Darwin',
'middleName': 'D',
'lastName': 'L',
'birthDate': 095545,
'mobile': 1256789,
'telephone': 12367891,
'presentAddress': 'mla',
'permanentAddress': 'mla',
'country': 'phl',
// 'title': 'Darwin',
// 'body': 'Success',
// 'userId': '1',
};
try{
var response = await dio.post(pathUrl, data: data, options: Options(
followRedirects: false,
validateStatus: (status) => true,
headers: {
'Content-type' : 'application/json; charset=UTF-8',
}
));
return response.data;
}catch(e){
print(e);
}
}`
This is the exact answer, this works for me.
Dio dio = Dio();
Future postData() async{
const String pathUrl = 'https://202.57.135.121:8443/icbs/ATMInterfaceListener/mobileAppRegistration';
dynamic data = {
'email': 'darwikf@gkdkkk.com',
'password': 'test123456',
'firstName': 'Darwin',
'middleName': 'D',
'lastName': 'L',
'birthDate': 095545,
'mobile': 1256789,
'telephone': 12367891,
'presentAddress': 'mla',
'permanentAddress': 'mla',
'country': 'phl',
};
try{
var response = await dio.post(pathUrl, data: data, options: Options(
followRedirects: false,
validateStatus: (status) => true,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
));
return response.data;
}catch(e){
print(e);
}
}