/ / ArangoDB: Błąd serwera podczas próby utworzenia wierzchołka za pomocą interfejsu gharial - python, bazy danych wykresów, arangodb, nosql

ArangoDB: Błąd serwera podczas próby utworzenia wierzchołka za pomocą interfejsu gharial - python, bazy danych wykresów, arangodb, nosql

Mam problemy z tworzeniem wierzchołków używając gharial za każdym razem próbuję wysłać niepusty ładunek.

Prosty kod, taki jak:

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

Zwraca a: <Response [500]>

Z następującym ciałem:

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 containednwithin the body into the given collection.n"},"context":"/"}}

Prowadzę ArangoDB 2.2.6.

Dzięki za pomoc,

Odpowiedzi:

3 dla odpowiedzi № 1

Powodem HTTP 500 jest to, że żądanie POST nie jest kodowane JSON.

Myślę, że powinno działać, jeśli kod jest dostosowany do:

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))