Rest Post Request

public ActionResult postRequest()
            using (var http = new HttpClient())
                // Define authorization headers here, if any
                // http.DefaultRequestHeaders.Add(“Authorization”, authorizationHeaderValue);
                var data = new sendParameter
                    token = pToken,
                    startDate = String.Format(“{0:yyyy/MM/dd}”, DateTime.Now.AddDays(-10)).Replace(“.”,”/”),
                    finishDate = String.Format(“{0:yyyy/MM/dd}”, DateTime.Now).Replace(“.”, “/”)
                var content = new StringContent(JsonConvert.SerializeObject(data));
                content.Headers.ContentType = new MediaTypeHeaderValue(“application/json”);
                var request = http.PostAsync(“post address”, content);
                var response = request.Result.Content.ReadAsStringAsync().Result;
                var objResponse1 =    JsonConvert.DeserializeObject<List<postObject>>(response);
                return Json(objResponse1, JsonRequestBehavior.AllowGet);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: