How to Solve {StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.

I want to send some data to API through POST method.While Debugging instead of json output I am getting this. So unable to deserialize json object. Any suggestion please..........

{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Cache-Control: no-cache, private Connection: close Date: Fri, 11 Jan 2019 05:10:42 GMT Server: Apache Transfer-Encoding: chunked Vary: Accept-Encoding,User-Agent X-Android-Received-Millis: 1547183571964 X-Android-Response-Source: NETWORK 500 X-Android-Selected-Protocol: http/1.1 X-Android-Sent-Millis: 1547183571710 X-Powered-By: PHP/7.2.6 Content-Type: text/html; charset=UTF-8 }} xamarin forms

This is my c# code.

public class StatusView
    public string status { get; set; }

class AddBillFun
    public async static Task<StatusView> AddBillData(string transaction_date1, string billing_date1, string vehicle_id1, string customer_id1, string fuel_id1
                                               , string fuel_unit_id1, string fuel_price_id1, string price_per_unit1, string quantity1, string amount1
                                               , string recieved_amount1, string advanced_amount1, string net_amount1, string _status1, string station_id1)

        StatusView statusCheck = new StatusView();
         Uri uri = new Uri(Constants.Bills_URL);
        var postData = new List<KeyValuePair<string, string>>
                new KeyValuePair<string, string>("transaction_date",transaction_date1),//"2018-10-05 12:16:11"
              new KeyValuePair<string, string>("billing_date",billing_date1 ),//"2018-10-05"
                new KeyValuePair<string, string>("vehicle_id",vehicle_id1),//"1"
                new KeyValuePair<string, string>("customer_id", customer_id1),//"1"
                new KeyValuePair<string, string>("fuel_id",fuel_id1),//"1"
                new KeyValuePair<string, string>("fuel_unit_id",fuel_unit_id1 ),//"1"
                new KeyValuePair<string, string>("fuel_price_id",fuel_price_id1 ),//"2"
                new KeyValuePair<string, string>("price_per_unit",price_per_unit1 ),//"70"
                new KeyValuePair<string, string>("quantity", quantity1),//"10"
                new KeyValuePair<string, string>("amount",amount1 ),//"700"
                new KeyValuePair<string, string>("received_amount",recieved_amount1 ),//"0"
                new KeyValuePair<string, string>("advance_amount", advanced_amount1 ),//"0"
                new KeyValuePair<string, string>("net_amount",net_amount1 ),//"700"
                new KeyValuePair<string, string>("status",_status1 ),//"success"
                new KeyValuePair<string, string>("station_id",station_id1 ),//"1"


        HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, uri);
        req.Content = new FormUrlEncodedContent(postData);

        using (HttpClient client = new HttpClient())
            var response = await client.SendAsync(req);

            var content = await response.Content.ReadAsStringAsync();

            statusCheck = JsonConvert.DeserializeObject<StatusView>(content);

        return statusCheck;



  • MonalishaMonalisha Member ✭✭

    I got solution.. Sorry for this silly question.In last line of var postdata, I just added a comma, So I was getting error

Sign In or Register to comment.