C# 来自asp.net的Scrapyd Post schedule.json

C# 来自asp.net的Scrapyd Post schedule.json,c#,asp.net,scrapy,scrapyd,C#,Asp.net,Scrapy,Scrapyd,我在Unix机器上安装了scrapyd和spider,运行时一切正常 curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider 我可以在ScrapydAPI的web界面上看到作业状态、日志和项目。简言之,一切都按预期进行 现在,我想通过编程方式启动一个spider,使用C#as scrapyd在ASP.Net中向API发送http post,这将是我的.Net项目的一部分,但我得到了 {

我在Unix机器上安装了scrapyd和spider,运行时一切正常

curl http://localhost:6800/schedule.json -d project=myproject -d spider=somespider
我可以在ScrapydAPI的web界面上看到作业状态、日志和项目。简言之,一切都按预期进行

现在,我想通过编程方式启动一个spider,使用C#as scrapyd在ASP.Net中向API发送http post,这将是我的.Net项目的一部分,但我得到了

{"status": "error", "message": "'project'"}
我发现了一个例子,它制作了一篇Jquery文章,这个例子对我很有用,但下面的一个对我不起作用

public void StartCrawler()
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://mydomain.com:6800/schedule.json");
            httpWebRequest.ContentType = "application/json; charset=utf-8";
            //httpWebRequest.ContentType = "text/json;; charset=utf-8";
            httpWebRequest.Method = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = "{\"project\":\"projectname\",\"spider\":\"spidername\"}";

                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var responseText = streamReader.ReadToEnd();
            }
        }
请告诉我我做错了什么

我已经解决了

public static string StartCraling(string URI, string Parameters)
        {
            WebRequest req = WebRequest.Create(URI);

            req.ContentType = "application/x-www-form-urlencoded";
            req.Method = "POST";

            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
            req.ContentLength = bytes.Length;

            using (Stream os = req.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length); //Push it out there
            }

            using (WebResponse resp = req.GetResponse())
            {
                using (StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()))
                {
                    return sr.ReadToEnd().Trim();
                }
            }
        }

参数对象的格式是什么?是Json吗?