locked
WEB API RRS feed

  • Question

  • User-1177023326 posted

    Good Day All,

    Please can anyone help to resolve the serious issues. I ve my web api with  Handler1.ashx  connecting android phone to database. But i this error is generated when running it.

    { "Successful": false, "ErrorMessage": "Internal server error" }

    This is my SERVICEAPI

    public class ServiceAPI : IServiceAPI
    {
    SqlConnection dbConnection;

    public ServiceAPI()
    {
    dbConnection = DBConnect.getConnection();
    }

    public string CreateIndividualTaxPayee(string Surname, string FirstName, string OtherNames, string Sex, string Address, string Address1, string Phone)
    {
    if (dbConnection.State.ToString() == "Closed")
    {
    dbConnection.Open();
    }

    SqlCommand cmdss = new SqlCommand("usp_MobileAndroid", dbConnection);
    cmdss.CommandType = CommandType.StoredProcedure;
    cmdss.Parameters.Add("@Surname", SqlDbType.VarChar).Value = Surname.Trim();
    cmdss.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = FirstName.Trim();
    cmdss.Parameters.Add("@OtherNames", SqlDbType.VarChar).Value = OtherNames.Trim();
    cmdss.Parameters.Add("@Sex", SqlDbType.VarChar).Value = Sex.Trim();
    cmdss.Parameters.Add("@Address1", SqlDbType.VarChar).Value = Address.Trim();
    cmdss.Parameters.Add("@Address", SqlDbType.VarChar).Value = Address1.Trim();
    cmdss.Parameters.Add("@Phone", SqlDbType.VarChar).Value = Phone.Trim();

    dbConnection.Open();

    int i = cmdss.ExecuteNonQuery();
    dbConnection.Close();

    dbConnection.Close();

    if (i >= 1)
    {
    return "Record Added Successfully";

    }
    else
    {
    return "Record Not Added";

    }

    This is my connection

    public class IServiceAPI
    {

    public class DBConnect
    {

    private static SqlConnection NewCon;
    private static string conStr = ConfigurationManager.ConnectionStrings["TAXSMART"].ConnectionString;

    public static SqlConnection getConnection()
    {
    NewCon = new SqlConnection(conStr);
    return NewCon;

    }
    public DBConnect()
    {

    }

    }
    }

    This is my handler

    public class Handler1 : JsonHandler
    {
    public Handler1()
    {
    this.service.Name = "JSONWebAPI";
    this.service.Description = "JSON API for android appliation";
    InterfaceConfiguration IConfig = new InterfaceConfiguration("RestAPI", typeof(IServiceAPI), typeof(ServiceAPI));
    this.service.Interfaces.Add(IConfig);
    }

    }

    Tuesday, August 2, 2016 12:31 PM

All replies

  • User-821857111 posted

    Check the Windows event log to see if it contains any information about the internal server error.

    Tuesday, August 2, 2016 4:11 PM