package required :
- Newtonsoft.Json
how to intall package Newtonsoft ?
- click reight in your project
- select manage Nuget Package
- select browse and search Newtonsoft
- install this package
#example GET
public class Something
{
public DateTimeOffset Date { get; set; }
public int TemperatureCelsius { get; set; }
public string Summary { get; set; }
}
HttpClientService c = new HttpClientService();
HttpRequestResponseDTO<string> apiCall = await c.ApiCall("http://reqbin.com/echo/get/json", HttpClientService.RequestMethod.GET);
PayloadCreateSomething res = JsonConvert.DeserializeObject<Something>(apiCall.Result);
#example POST
var payload = new PayloadCreateSomething
{
Date = DateTime.Parse("2019-08-01"),
TemperatureCelsius = 25,
Summary = "Hot"
};
string jsonString = JsonConvert.SerializeObject(payload);
HttpRequestResponseDTO<string> post = await c.ApiCall("http://reqbin.com/echo/get/json", HttpClientService.RequestMethod.POST, jsonString);