I have the code below:
Here is my MVC Action Method
[HttpPost]
public ActionResult SaveOrder(myObject obj)
{
HelperClass.CreateOrder(obj.orderid, obj.ordername, out response);
}
In my helper class is the CreatOrder function as follows:
public static object CreateOrder(string orderid, string ordername, out bool response)
{
response = false;
try
{
var client = new RestClient();
var request = new RestRequest("url", Method.POST);
request.AddHeader("Authorization", "Bearer " + "mytoken");
var body = new
{
orderid = orderid,
ordername = ordername
};
request.AddJsonBody(body);
var response = client.Execute(request); <---- this execute gives Status 0
.........
}
catch (Exception ex)
{
throw ex;
}
}
Is this possible since i am already making a HttpPost from within the Action method ? How can i do the Api call and get back the result ?