Consume restful web service into console app

  • Thread starter Thread starter Hasim Marfatiya
  • Start date Start date
H

Hasim Marfatiya

Guest
Hello Guys,

I use rest sharp to call web services.

var client = new RestClient("https://api.portasigma.com/v1/docs/");
client.Timeout = 120000; //2 min
client.ReadWriteTimeout = 120000;
var request = new RestRequest(Method.POST);
//header setting
request.AddHeader("authorization", "Basic *******");
request.AddHeader("accept", "application/json");
request.AddHeader("cache-control", "no-cache");
//final data
request.AddParameter("description", "Simple Invoice Format");
request.AddParameter("comments", "Sample Invoice Documents For Testing");
request.AddFile("file", filepath);
//execute request
IRestResponse response = new RestResponse();
response = client.Execute(request);
if (response.IsSuccessful)
{
JObject jObj = JObject.Parse(response.Content);
docGuid = jObj["id"].ToString();
}
else
{
docGuid = string.Empty;
}

In Above Code I got error when execute this line of code

response = client.Execute(request);

The error is "The Operation has Time out"

"StatusCode: 0, Content-Type: , Content-Length: 0)"

I don't Know about this pls suggest me

Thanks For Help !!!

Continue reading...
 
Back
Top