How to pass a post with an array to a URL of a WebFORM

2

I'm trying to send an array with some elements in a post to a url.

I called WebBroser method, I passed the parameters, but I still had no idea how to finish implementing.

Follow my code:

   private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("MINHA_URL");
        request.Method = "POST";
        request.Accept = "application/json";
        request.UserAgent = "curl/7.37.0";
        request.ContentType = "application/x-www-form-urlencoded";

        using (var streamWriter = new StreamWriter(request.GetRequestStream()))
        {
            string data = "browser=Win7x64-C1|Chrome32|1024x768&url=http://www.google.com";

            streamWriter.Write(data);
        }

    }
    private void label2_Click(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
        var lista = new string[]
        {
            info.nome,
            info.idade,
              info.estado= "H",
           //DAQUI PRA BAIXO JÁ É PRÉ-DEFINIDO

            info.regiao,
            info.tipousuario = "X",
            info.formulario = "0",
            info.t = "+",
            info.v = "",
            info.pop = "",
            info.t= "",
            info.p= "",
            info.t= "x",
            info.r= "x",
            info.e= "2",
            info.f= "n",
            info.id= ""
        };

         webBrowser1_DocumentCompleted(lista, null);
    }

    #region inputs
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
        info.estado= textBox1.Text;
    }

    private void textBox2_TextChanged(object sender, EventArgs e)
    {

        info.nome= textBox2.Text;
    }

    private void textBox3_TextChanged(object sender, EventArgs e)
    {
        info.idade= textBox3.Text;
    }
    #endregion
    
asked by anonymous 09.10.2015 / 04:27

1 answer

0

Apparently everything is all right. You just have to collect the answer:

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("MINHA_URL");
    request.Method = "POST";
    request.Accept = "application/json";
    request.UserAgent = "curl/7.37.0";
    request.ContentType = "application/x-www-form-urlencoded";
    request.KeepAlive = false;

    using (var streamWriter = new StreamWriter(request.GetRequestStream()))
    {
        string data = "browser=Win7x64-C1|Chrome32|1024x768&url=http://www.google.com";

        streamWriter.Write(data);
    }

    WebResponse response = request.GetResponse();
}
    
09.10.2015 / 18:22