1
I am trying to access the Pagseguro API to view the account balance but the following error appears. (I deleted my email and token in the print as well as in the code below).
Code on the controller:
string url = String.Format("https://ws.pagseguro.uol.com.br/transfer/balance?email=&token=");
//Classe que irá fazer a requisição GET.
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
//Método do webrequest.
request.Method = "GET";
request.ContentType = "application/vnd.pagseguro.com.br.v1+json";
request.UseDefaultCredentials = true;
request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Obtém resposta do servidor.
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
//Cria stream para obter retorno.
using (Stream dataStream = response.GetResponseStream())
{
//Lê stream.
using (StreamReader reader = new StreamReader(dataStream))
{
}
}
}
return View();
if your credentials are correct, it may be a problem of ssl validation. Try adding this line after creating the
Request
:ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
– Ricardo Pontual
have tried via Postman?
– Tmilitino
via Postman not yet, I will do the tests and give the feedback, thank you very much for the help.
– Vinícius Eugênio