正如标题中简要描述的那样,我试图将大约9400个项目添加到实时数据库中,因此我在JArray中循环播放500个项目,每次调用之间的延迟时间为90秒。虽然它第一次完全正常工作,但它总是在第二轮抛出Error-Code 400。如果有人知道如何解决这个问题,请帮忙!
我的要求代码:
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++;
}
}
答案 0 :(得分:0)
解决方案:错误在JSON中,我在文档中找到了一个条目,即键名中不允许使用某些字符!