public string Create(MakeAddModel make) { var http = (HttpWebRequest)WebRequest.Create(new Uri(_url)); http.Accept = "application/json"; http.ContentType = "application/json"; http.Method = "POST"; string parsedContent = JsonConvert.SerializeObject(make); UTF8Encoding encoding = new UTF8Encoding(); Byte[] bytes = encoding.GetBytes(parsedContent); Stream newStream = http.GetRequestStream(); newStream.Write(bytes, 0, bytes.Length); newStream.Close(); var response = http.GetResponse(); var stream = response.GetResponseStream(); var sr = new StreamReader(stream); var content = sr.ReadToEnd(); return(content.ToString()); }
public Task <string> CreateAsync(MakeAddModel make) { return(Task.Run(() => Create(make))); }