【问题标题】:ArangoDB: Server error when trying to create a vertex using gharial interfaceArangoDB:尝试使用 gharial 接口创建顶点时出现服务器错误
【发布时间】:2015-01-15 01:16:23
【问题描述】:

每次我尝试发送非空有效负载时,我都会遇到使用 gharial 创建顶点的问题。

简单的代码如:

import requests
url = "http://localhost:8529/_db/test_db/_api/gharial/MyGraph/vertex/Humans"
payload = {"name" : "tesla"}
r = requests.post(url, data = payload)

返回一个:<Response [500]>

具有以下主体:

A runtime error occurred while executing an action: SyntaxError: Unexpected token a SyntaxError: Unexpected token a
  at Object.parse (native)
  at Object.requestFunctions.body ([object Object]:23:21)
  at extractElement (/usr/share/arangodb/js/server/modules/org/arangodb/foxx/request_context.js:56:18)
  at /usr/share/arangodb/js/server/modules/org/arangodb/foxx/request_context.js:75:45
  at execute (/usr/share/arangodb/js/server/modules/org/arangodb/actions.js:951:7)
  at next (/usr/share/arangodb/js/server/modules/org/arangodb/actions.js:968:7)
  at [object Object]:169:5
  at execute (/usr/share/arangodb/js/server/modules/org/arangodb/actions.js:951:7)
  at Object.routeRequest (/usr/share/arangodb/js/server/modules/org/arangodb/actions.js:972:3)
  at Function.actions.defineHttp.callback (/usr/share/arangodb/js/actions/api-system.js:52:15)

This error was triggered by the following route {"path":"/_api/gharial/[^/]+/vertex/[^/]+","regexp":{},"prefix":false,"depth":5,"urlParameters":{"graph":2,"collection":4},"callback":{"options":{},"methods":["DELETE","GET","HEAD","OPTIONS","POST","PUT","PATCH"]},"route":{"url":{"match":"/:graph/vertex/:collection","methods":["post"],"constraint":{"graph":"/[^/]+/","collection":"/[^/]+/"}},"action":{},"docs":{"parameters":[{"name":"vertex","paramType":"body","description":"The document to be stored","dataType":"vertex"},{"paramType":"path","name":"graph","description":"Name of the graph.","dataType":"string"},{"paramType":"path","name":"collection","description":"Name of the vertex collection.","dataType":"string"},{"paramType":"query","name":"waitForSync","description":"define if the request should wait until synced to disk.","dataType":"boolean"}],"errorResponses":[{"code":404,"reason":"Graph or collection not found."}],"httpMethod":"POST","nickname":"post_graph_vertex_collection","summary":"Create a new vertex.","notes":"\nStores a new vertex with the information contained\nwithin the body into the given collection.\n"},"context":"/"}}

我正在运行 ArangoDB 2.2.6。

感谢您的帮助,

【问题讨论】:

    标签: python graph-databases arangodb nosql


    【解决方案1】:

    HTTP 500 的原因是 POST 请求不是 JSON 编码的。

    我认为如果将代码调整为:

    import requests
    import json
    url = "http://localhost:8529/_db/test_db/_api/gharial/MyGraph/vertex/Humans"
    payload = {"name" : "tesla"}
    r = requests.post(url, data = json.dumps(payload))
    

    【讨论】:

      猜你喜欢
      • 2021-01-19
      • 1970-01-01
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-25
      • 2017-09-05
      • 1970-01-01
      相关资源
      最近更新 更多