1
I’m trying to integrate Cielo to make payments on my site "Asp.Net MVC" but I’m not getting it. I read the Cielo integration manual, followed all the steps, performed tests in Postman and works well, but in my application I am not able to make it work, always returns the error: Method Not Allowed and looking at Cielo’s website, I couldn’t find a way to solve this problem.
For integration, I tested using Httpclient and Restsharp and both return the same error.
How to solve this problem ?
//pagamento com cartão
public static bool Pay(CieloObject obj){
try{
string URL_FINAL = "https://apisandbox.cieloecommerce.cielo.com.br";
string mid = "<meu-id>";
string key = "<minha-chave>";
var request = new RestRequest();
request.Method = Method.POST;
request.AddHeader("content-type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddHeader("MerchantId", mid);
request.AddHeader("MerchantKey", key);
request.Parameters.Clear();
request.AddParameter("application/json", JsonConvert.SerializeObject(obj), ParameterType.RequestBody);
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var client = new RestClient(URL_FINAL);
var response = client.Execute(request);
Debug.WriteLine(response.StatusDescription);
return true;
}catch(Exception e){
return false;
}
}
I may be talking nonsense, but don’t you need to pass something after "https://apisandbox.cieloecommerce.cielo.com.br/METODO"? He doesn’t have a bar after that?
– Leonardo Buta
@Leonardobuta does not. See: https://developercielo.github.io/manual/cielo-ecommerce
– FernandoPaiva
According to the website of Mozilla this answer means that the method used (POST) is not allowed, check if the url is correct and if the method is POST even... Some servers are case sensitive for headers, try using the "Content-Type" header (with uppercase initials).
– user178974
@Edney is POST yes. Even in Postman works with POST
– FernandoPaiva
I am not very familiar with this API, Cielo does not have a technical support that meets?
– user178974
@Edney emailed me and there’s no reply
– FernandoPaiva
I took a look at your link and it seems that the requests are made at: https://apisandbox.cieloecommerce.cielo.com.br/1/sales/
– user178974
don’t forget the "https://"
– user178974
@Edney worked. The problem was Webdav. I found the solution here: https://stackoverflow.com/questions/9854602/asp-net-web-api-405-http-verb-used-to-accessthis-page-is-not-allowed-how
– FernandoPaiva