【发布时间】:2016-09-30 01:10:46
【问题描述】:
我正在尝试将数千条记录导入 Arango。我正在尝试使用 Arango 的批量/批量导入功能:https://docs.arangodb.com/3.0/HTTP/BatchRequest/index.html 进行 PUT 和 POST 请求的组合,以插入新记录或更新现有记录(如果它们已经存在)。我的最终解决方案需要从 Python 脚本运行,大概是使用 pyArango。我创建了一个示例 HTTP 请求
POST http://<arango_server>:8529/_db/myDB/_api/batch
看起来像下面这样:
Content-Type: multipart/form-data; boundary=P1X7QNCB
Content-Length: <calculated by python or REST Client>
Authorization: Basic <calculated by python requests session or REST Client>
--P1X7QNCB
Content-type: application/x-arango-batchpart
Content-Id: 1
POST /_api/document/model/foo HTTP/1.1
{"data": "bar"}
--P1X7QNCB
我无法在 Arango 中成功处理此问题。我尝试过使用类似于以下的python(即使我对下面代码的近似有错别字,也会生成上述请求):
url = "/_api/document/" + collection + "/" + nodeKey + " HTTP/1.1"
postString = ("--P1X7QNCB\r\n"
"Content-type: application/x-arango-batchpart\r\n"
"Content-Id: " + str(counter) + "\r\n"
"\r\n"
"\r\n"
"PUT " + url+ "\r\n\r\n\r\n" + json.dumps(nodeData) + "\r\n")
batchHeaders = {"Content-Type": "multipart/form-data; boundary=P1X7QNCB"}
response = self.db.connection.session.post(self.db.URL + "/batch", data=postString, headers=batchHeaders)
并使用我手动发布内容的 REST 客户端。在这两种情况下,我都会得到以下回复:
{"error":true,"errorMessage":"invalid multipart message received","code":400,"errorNum":400}
并且在arango日志文件中记录了以下内容:
WARNING received a corrupted multipart message
我做错了什么对任何人都很明显,或者我可以在哪里查找有关 ArangoDB 拒绝请求的原因的更多详细信息?
谢谢!
【问题讨论】: