I return an empy string when doing this HttpWebRequest

Andreas ss 721 Reputation points


I am trying to do a HttpWebRequest to the below URL. When I do that, I return an empty string.

However, when I put the URL manually in the chrome browser. There is a large JSON string on this URL.

I wonder why I return an empy string with the below URL?

Thank you!

                String URL = "https://api.etherscan.io/api?module=account&action=txlist&address=0xea482c608fedbaebb2bee4456d19acb3270f8355&startblock=12226259&endblock=99999999&sort=asc&apikey=1BDWT2SMX7KPV21FXPT932GZPMX4";

                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(URL);
                myRequest.Timeout = 60000;
                myRequest.Method = "GET";
                myRequest.Accept = "application/json";
                myRequest.ContentType = "application/json; charset=utf-8";
                WebResponse myResponse = myRequest.GetResponse();

                var response = (System.Net.HttpWebResponse)myRequest.GetResponse();
                String responseString = new System.IO.StreamReader(response.GetResponseStream()).ReadToEnd();

            catch(Exception ex) { MessageBox.Show(ex.ToString()); }
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,214 questions
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 71,866 Reputation points

    I just tested and the string is not empy

    If you replace the MessageBox by :


    it is displayed in the Output window

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful