During all week I had problems in the calls to their API, I get only the following error:
The underlying connection was closed unexpected error in a submission
My code called in RestSharp is:
public Transaction Transaction_CreditCard(Transaction transaction)
{
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "text/json");
request.AddHeader("merchantkey", this.merchantKey);
request.AddHeader("merchantid", this.merchantID);
request.AddParameter("application/json", JsonConvert.SerializeObject(transaction), ParameterType.RequestBody);
return Execute<Transaction>(request, this.apiUrl);
}
private T Execute<T>(RestRequest request, string url) where T : new()
{
var cliente = new RestClient(url);
var response = cliente.Execute<T>(request);
if (response.ErrorException != null)
{
string message = "Erro durante a requisição " + request.Resource;
var cieloException = new ApplicationException(message, response.ErrorException);
throw cieloException;
}
return response.Data;
}
But my response.ContentLength
is equal to 0
. I already configured SSL on my site, I already added user-agent
and it did not solve either
What could be happening?