using (HttpClient httpclient = new HttpClient())
{
string url = "http://localhost:51411/api/MobileAPI/Inventory?TenantId=" + CommonClass.tenantId + "";
String uriToCall = String.Format(url);
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("", str)
});
}
I am not getting how to start so please can anyone can help me.
I tried this by reading some google articles but still its not fine....
string str = Inventory();
//HttpClient http = new HttpClient();
using (HttpClient httpclient = new HttpClient())
{
var http = (HttpWebRequest)WebRequest.Create(new Uri("http://localhost:51411/api/MobileAPI/Inventory?TenantId='" + CommonClass.tenantId + "'&JsonInventory='" + str));
http.Accept = "application/json";
http.ContentType = "application/json";
http.Method = "POST";
}
and my web API code is
[HttpPost]
[AcceptVerbs("POST")]
public HttpResponseMessage Inventory(long TanantId, [FromBody]string JsonInventory)
{
try
{
List<Inventory> lstInventory = JsonConvert.DeserializeObject<List<Inventory>>(JsonInventory);
foreach (var item in lstInventory)
{
}
return new HttpResponseMessage(HttpStatusCode.OK);
}
catch (Exception ex)
{
throw ex;
}
}
My Inventory Model is this
public class Inventory
{
public string ItemId { get; set; }
public string Category { get; set; }
public decimal Price1 { get; set; }
public string Description { get; set; }
public int QuantityAvailable { get; set; }
public int QuantityOnHand { get; set; }
public string Method { get; set; }
}
I want to call my web API Inventory Method via url and send collection of json string data.
please help me how to call url then during calling my break point hit