Problems accessing external C#API

Asked

Viewed 98 times

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).

inserir a descrição da imagem aqui

Document print: inserir a descrição da imagem aqui

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);

  • have tried via Postman?

  • via Postman not yet, I will do the tests and give the feedback, thank you very much for the help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.