Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i write insert, delete function in C#. I need to check those functions in Restapi. Whenever i check it says error and in function parameters are always null. My c# code is,

C#
[HttpPost]
        public HttpResponseMessage InsertOrganizationDetails(Organization[] Organization)
        {
            try
            {
                return new HttpResponseMessage()
                {
                    Content = new StringContent(string.Concat(crudorganization.InsertOrganizationDetails(Organization)), Encoding.UTF8, "application/json")
                };
            }
            catch (Exception ex)
            {
                RevshopWebAPI.Global.LogFile.Log.WriteLog("Exception in method - GetOrganizationDetails ", ex.ToString(), RevshopWebAPI.Global.LogType.Error);
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }


The following is inside crudorganization class,

C#
public object InsertOrganizationDetails(Organization[] Organization)
        {
            try
            {
                DataSet ds = new DataSet();

                for (int i = 0; i < Organization.Length; i++)
                {
                    object[] objParamValue = { Organization[i].Type, Organization[i].Parent, Organization[i].Company, Organization[i].Address_1, Organization[i].Address_2, Organization[i].City, Organization[i].State, Organization[i].Zip, Organization[i].Country, Organization[i].Phone, Organization[i].Fax };

                    ds = sqlHelper.GetDataset(connStr, Procedures.InsertOrganizationDetails, ProcedureParams.InsertOrganizationDetailsParameter, objParamValue);
                }

                return jsonUtility.serializetoJSON("1");
            }
            catch (Exception ex)
            {
                LogFile.Log.WriteLog(ex.ToString(), ex.Message);
                throw ex;
            }
        }


Whenever i tried in API and select post option then click send button i get the following error message,

Abort / timeout

The request has been aborted manually or because of the conection timeout. There were no response from the server but the connection wasn't closed.

You can adjust timeout in settings.

Try to:

add "Connection: close" header which should be used by the server to close the connection after it finish generating response
Please, check if:

all required services (like www) are up and running on server
method is correct
port number is correct
url is correct
all required headers and/or payload has been added to the request
Example

Sometimes it may happen when you use http protocol instead of https. Also it may happen when you use different URL (port / protocol) and the server is not configured properly.

Please help me.

What I have tried:

I am not getting what ever i tried.
Posted
Updated 3-Oct-16 0:48am
v2
Comments
David_Wimbley 3-Oct-16 9:55am    
Without you posting what you are sending as test data I don't think it'll be feasible to help you at the moment.

For example, your issue could be in your content type headers you are using, or it could be that you are sending a JSON string instead of form data array.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900