2

I'm having problems with vertex creation using gharial everytime i try to send a non-empty payload.

A simple code such as:

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

Returns a: <Response [500]>

With the following body:

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":"/"}}

I'm running ArangoDB 2.2.6.

Thanks for your help,

1 Answer 1

3

The reason for the HTTP 500 is that the POST request is not JSON-encoded.

I think it should work if the code is adjusted to:

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.