2
All week long I have had problems in calling their API, I get only the following error:
The underlying connection was closed unexpected error in a send
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 mine response.ContentLength
is equal to 0
. I already set up SSL on my site, already add the user-agent
and didn’t solve either
What might be going on?
You implemented the payment by Cielo ? can send me an example ?
– FernandoPaiva