I know how to retrieve with one string in webapi. But I dont know how to use hashtable with my webapi. Because in hashtable i have different condition for each form but calling same api.
I am using .net3.5
Example:
System.Collections.Hashtable _condition = new System.Collections.Hashtable();
if (TPX.StringHelper.NVL(cbxStatus.EditValue, "-Please Select-") != "-Please Select-")
_condition.Add("Status", cbxStatus.EditValue.ToString());
if (TPX.StringHelper.NVL(cbxCenter.EditValue, "-Please Select-") != "-Please Select-")
_condition.Add("Center", cbxCenter.EditValue.ToString());
if (chkHideDone.Checked)
_condition.Add("IsDone", Convert.ToInt32(!chkHideDone.Checked));
_condition.Add("StartDate", dtpBegin.DateTime.ToString("yyyyMMdd"));
_condition.Add("EndDate", dtpEnd.DateTime.ToString("yyyyMMdd"));
string itemJson = Newtonsoft.Json.JsonConvert.SerializeObject(_condition);
string navURL = GlobalParameters.Host + "api/Order/RetrieveOrderList?conditions="+itemJson;
using (System.Net.WebClient webClient = new System.Net.WebClient())
{
webClient.Headers["Content-Type"] = "application/json";
webClient.Encoding = Encoding.UTF8;
string sJson = webClient.DownloadString(navURL); List<Models.OrderList> myDeserializedObjList = (List<Models.OrderList>)Newtonsoft.Json.JsonConvert.DeserializeObject(sJson, typeof(List<Models.OrderList>));
grdOrder.DataSource = myDeserializedObjList;
}
It is giving error while downloading string (webclient.downloadstring(navURL)). Note: I have copied same logic to create one more and filtered by one field instead of hashtable i have no issues. I really need hashtbale, because I use same logic in different places on my project, only the supplied condition is different.
I really appreciate for any valuable input. Thanks.