Reputation: 19
**flutter**
As you can see below code of post method in which i pass static data for post through post API, those data are work in postman but not in this method
Future addbuss() async {
var urlpost = "https://jcien.com/api/addBusinessReceived";
var responce = await http.post(urlpost,
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode({
"user": "7",
"ch_id": "1",
"user_from": "9",
"entry_date": "2021-05-31",
"amount": "1234",
"business_type": "new",
"referral_type": "inside",
"remarks": "demoapii",
}));
print(responce.statusCode);
**statusCode**
status code showing error of 500
}
Upvotes: 1
Views: 1981
Reputation: 34
I think It might be because of
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
Use this instead
headers: {
'Content-Type': 'application/json'
},
Upvotes: 0
Reputation: 96
You must debug your API, the error is from there. Check log server.
Upvotes: 0