public void POST(object model, string apiController)
        {
            try
            {
                {
                    var request = WebRequest.Create(stringUrl + apiController);
                    request.Method      = "POST";
                    request.ContentType = "application/json";

                    var requestContent = JsonConvert.SerializeObject(model);
                    var data           = Encoding.UTF8.GetBytes(requestContent);
                    request.ContentLength = data.Length;

                    using (var requestStream = request.GetRequestStream())
                    {
                        requestStream.Write(data, 0, data.Length);
                        requestStream.Flush();

                        using (var response = request.GetResponse())
                        {
                            using (var streamItem = response.GetResponseStream())
                            {
                                using (var reader = new StreamReader(streamItem))
                                {
                                    var result = reader.ReadToEnd();
                                    Console.WriteLine(result);
                                }
                            }
                        }
                    }
                }
                _OutputClient.WriteLine("Saved Successfully !!");
            }
            catch (Exception ex) { _OutputClient.WriteLine(ex.Message); };
        }
Example #2
0
 public void InitialMessage()
 {
     _OutputClient.WriteLine("================================");
 }