Shivam Patel
Shivam Patel

Reputation: 19

flutter http post request showing status code 500 although its works in postman

**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

Answers (3)

The error message is self-explanatory:

enter image description here

Upvotes: 1

Rayyan Maqsood
Rayyan Maqsood

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

Bakhouche Akram
Bakhouche Akram

Reputation: 96

You must debug your API, the error is from there. Check log server.

Upvotes: 0

Related Questions