I have three keys personname,billingdate and nozzolereadings...I am able to work with name and date as it is simple string but nozzolereadings is asking for json object as a value..
My required json request is:
personname name
billingdate 2019-01-01
nozzolereadings [{"opening_reading":"7687","closing_reading":"7691289"},{"opening_reading":"103250","closing_reading":"103348"}]
Anyone suggest please how to send [{"opening_reading":"7687","closing_reading":"7691289"},{"opening_reading":"103250","closing_reading":"103348"}] as value to post request ?This is my code for sending request to API and getting response...
class Bill
{
public async static Task AddBillData(string name,string date)
{
Uri uri = new Uri(urlname);
var postData = new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("personname",name),
new KeyValuePair<string, string>("billingdate",date),
};
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;
}
}