批量请求 ArangoDB 失败
Batch Requests into ArangoDB failing
我正在尝试将数千条记录导入 Arango。我正在尝试使用 Arango 的 batch/bulk 导入功能,在 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)
并使用我手动 post 内容的 REST 客户端。在这两种情况下,我都会得到以下回复:
{"error":true,"errorMessage":"invalid multipart message received","code":400,"errorNum":400}
并且在 arango 日志文件中记录了以下内容:
WARNING received a corrupted multipart message
任何人都清楚我做错了什么,或者我可以在哪里查找有关 ArangoDB 拒绝请求的原因的更多详细信息?
谢谢!
ArangoDB 在尝试提取 next part of a multipart mime container 但失败时将抛出此错误。
您应该检查您的边界字符串,并检查最后一个字符串是否以两个尾部破折号正确终止容器 (--
)
NGrep or Wireshark 往往对于检查程序真正发送的内容非常有用 - 有时可能不是你所想的 - 甚至可以从其他程序中获取如何执行此操作的示例。
我正在尝试将数千条记录导入 Arango。我正在尝试使用 Arango 的 batch/bulk 导入功能,在 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)
并使用我手动 post 内容的 REST 客户端。在这两种情况下,我都会得到以下回复:
{"error":true,"errorMessage":"invalid multipart message received","code":400,"errorNum":400}
并且在 arango 日志文件中记录了以下内容:
WARNING received a corrupted multipart message
任何人都清楚我做错了什么,或者我可以在哪里查找有关 ArangoDB 拒绝请求的原因的更多详细信息?
谢谢!
ArangoDB 在尝试提取 next part of a multipart mime container 但失败时将抛出此错误。
您应该检查您的边界字符串,并检查最后一个字符串是否以两个尾部破折号正确终止容器 (--
)
NGrep or Wireshark 往往对于检查程序真正发送的内容非常有用 - 有时可能不是你所想的 - 甚至可以从其他程序中获取如何执行此操作的示例。