使用Rest API创建顶点时出错500

使用Rest API创建顶点时出错500,rest,orientdb,Rest,Orientdb,我正在编写一个SSIS脚本组件,用于使用RestAPI将数据导入orientdb,但出现错误500。求你了,我被困在这里了。有人能帮我吗。我使用的是2.1.7版社区版。 这是到目前为止我的代码 Uri address = new Uri("http://localhost:2480//command/SQ-DB/sql/"); HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest; re

我正在编写一个SSIS脚本组件,用于使用RestAPI将数据导入orientdb,但出现错误500。求你了,我被困在这里了。有人能帮我吗。我使用的是2.1.7版社区版。 这是到目前为止我的代码

    Uri address = new Uri("http://localhost:2480//command/SQ-DB/sql/");
    HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;
    request.Method = "POST";
    request.Accept = "application/json; charset=UTF-8";
    request.ContentType = "application/json";
    string username = "root";
    string password = "***";
    String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
    request.Headers.Add("Authorization", "Basic " + encoded);
    StringBuilder data = new StringBuilder();
   // string link = "{\"statements\" : [ {\"statement\" : \"CREATE ( company: Accounts { Name:" + Row.companyname + "} ) RETURN company\"} ]}";
    string link= "CREATE VERTEX Contacts CONTENT { 'name' : "+ Row.fullname+", 'Email' : "+ Row.emailaddress1+", 'Phone' : "+ Row.telephone1 + ", 'ContactId' : "+ Row.contactid+", 'City' : "+Row.address1city+"}" ;
    data.Append(HttpUtility.UrlEncode(link));
    // Create a byte array of the data we want to send
    byte[] byteData = UTF8Encoding.UTF8.GetBytes(data.ToString());
    // Set the content length in the request headers
    request.ContentLength = byteData.Length;
    request.Headers.Add("Accept-Encoding", "gzip,deflate");
    using (Stream postStream = request.GetRequestStream())
    {
        postStream.Write(byteData, 0, byteData.Length);
    }
    // Get response
    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        // Get the response stream
        StreamReader reader = new StreamReader(response.GetResponseStream());
        // Console application output
        Console.WriteLine(reader.ReadToEnd());
    }

如果有人能指出这个问题,那将是一个很大的帮助。谢谢你

你能在这里发布回复吗?@wolf4ood抱歉,我对这一切都不熟悉。我不知道从哪里得到答复。我现在尝试了另一个编辑,仍然得到一个错误,但它是不同的。现在错误是(远程服务器返回错误:(405)方法不允许。)405可能意味着url错误。我是指http调用的响应。500是响应状态,但您应该能够打印结果text@wolf4ood我已经解决了这个问题。它与将rquest主体编码为url有关。它不需要url编码。你能在这里发布回复吗?@wolf4ood抱歉,我对这一切都不熟悉。我不知道从哪里得到答复。我现在尝试了另一个编辑,仍然得到一个错误,但它是不同的。现在错误是(远程服务器返回错误:(405)方法不允许。)405可能意味着url错误。我是指http调用的响应。500是响应状态,但您应该能够打印结果text@wolf4ood我已经解决了这个问题。它与将rquest主体编码为url有关。它不需要url编码