1

My Post Method for System.Net is

public string Post(string url, string postdata, string referrer = "https://accounts.epicgames.com/login?productName=epic-games&redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fsite%2Fen-US%2Fhome&noHostRedirect=true", string accept = "*/*")
{
    var req = (HttpWebRequest)WebRequest.Create(url);
    byte[] postData = Encoding.UTF8.GetBytes(Uri.EscapeUriString(postdata));
    req.Method = "POST";
    req.Accept = accept;
    req.UserAgent = useragent;
    req.Timeout = 10000;
    req.ReadWriteTimeout = 15000;
    if (Useproxy) req.Proxy = HProxy;
    req.Headers.Add("Origin", "https://accounts.epicgames.com");
    req.Headers.Add("Accept-Language", "en-GB,en-US;q=0.9,en;q=0.8");
    req.Headers.Add("Accept-Encoding", "gzip, deflate, br");
    req.Referer = referrer;
    req.ContentType = "application/x-www-form-urlencoded";
    req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
    req.KeepAlive = true;
    req.CookieContainer = cookies;
    using (var s = req.GetRequestStream())
    {
        s.Write(postData, 0, postData.Length);
    }
    var res = (HttpWebResponse)req.GetResponse();

    using (var sr = new StreamReader(res.GetResponseStream()))
    {
        return sr.ReadToEnd();
    }
}

In my Main Method I have this

public void DoWork()
{
    string source = string.Empty;

    try
    {
        string account = "account here";
        string[] combo = account.Split(':', ';', '|');
        var req = new HttpReq();
        var x = req.Get("https://accounts.epicgames.com/login/doLogin?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fsite%2Fen-US%2Fhome&productName=epic-games");
        string xsrf = Regex.Match(x, "value=\"([a-z0-9-]{36})\"").Groups[1].Value;
        string pData = $"X-XSRF-TOKEN={xsrf}&X-XSRF-URI=%2Flogin%2FdoLogin&fromForm=yes&authType=&linkExtAuth=&redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fsite%2Fen-US%2Fhome&epic_username={WebUtility.UrlEncode(combo[0])}&password={combo[1]}&productName=epic-games";
        var y = req.Post("https://accounts.epicgames.com/login/doLogin", pData);
        MessageBox.Show(y);
        //do normal login and see get url and post url again. It wa still same issuemeanslets see

    }
    catch (WebException wex)
    {
        MessageBox.Show(wex.Message);
        //if (wex.Response != null)
        //{
        //    using (var errorResponse = (HttpWebResponse)wex.Response)
        //    {
        //        using (var reader = new StreamReader(errorResponse.GetResponseStream()))
        //        {
        //            string error = reader.ReadToEnd();
        //            //TODO: use JSON.net to parse this string and look at the error message
        //            Clipboard.SetText(error);
        //        }
        //    }
        //}
    }
} 

I have followed some questions on this site, and in syntax it seems correct. However when posting to a site I'm getting 400 Bad Request.
When I read what the error is, it states this:

Sorry, it appears that you have tried to submit the form twice. Please click only once.

I'm certain that everything works because I have the same system working in xNet. I'm switching because xNet is not capable of doing what I need.

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
KeCa
  • 11
  • 3

0 Answers0