tobbbe
8/20/2014 - 9:26 AM

POST request with data

POST request with data

bool errorWhileSubscribing = false;
    try
    {
        var wq = new WebClient();
        wq.Headers.Add(HttpRequestHeader.Authorization, GANconfig.token);
        NameValueCollection formData = new NameValueCollection();
        formData["contact"] = Membership.GetUser().Email;

        byte[] responseBytes = wq.UploadValues("https://api.getanewsletter.com/v3/lists/" + GANconfig.listhash + "/subscribers/", "POST", formData);
        string resultAuthTicket = System.Text.Encoding.UTF8.GetString(responseBytes);
    }
    catch (Exception e)
    {
        errorWhileSubscribing = true;
        Response.Write(e.Message);
    }

    if (!errorWhileSubscribing)
    {
        Response.Redirect("/login?subscriptions=view");
    }