0

As briefly described in the title im trying to add around 9400 items into the realtime-database and am therefore looping through my JArray for 500 items each call with a delay of 90sec between each call. While it totally works fine the first time, it always throws Error-Code 400 in the 2nd round. If anyone knows how to fix that please help!

My Request Code:

            var baseAddress = "my database base url";
            var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
            http.Accept = "application/json";
            http.ContentType = "application/json";
            http.Method = "PATCH";

            string parsedContent = JsonConvert.SerializeObject(Skins);
            using (StreamWriter streamWriter = new StreamWriter(http.GetRequestStream()))
            {
                streamWriter.Write(parsedContent);
                streamWriter.Flush();
                streamWriter.Close();
            }
            WebResponse httpsresponse = http.GetResponse();

            Stream stream = httpsresponse.GetResponseStream();
            StreamReader sr = new StreamReader(stream);
            string response = sr.ReadToEnd();
            //MessageBox.Show(response);

My Loop:

            foreach (JToken Skin in body)
            {
                if (i == 500)
                {
                    new Thread(delegate ()
                    {
                        DODB(Skins);
                    }).Start();
                    Thread.Sleep(90000);
                    i = 0;
                    Skins = new JObject();
                }
                else
                {
                    Skins.Add(Skin);
                    i++;
                }
            }

1 Answers1

0

SOLUTION: The error was inside the JSON, I found an entry in the docs that some characters are not allowed in a key-name!