-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Requests with endpoint="/_api/simple/..." fail #270
Comments
Hello @dpro-shc, Based on the error you provided, I have a few observations and questions:
I tried replicating the error on my end, but everything seems to work as expected. I'll post a working example below for your reference. Perhaps you can compare it with your code to see if there are any differences. from arango import ArangoClient
client = ArangoClient(hosts="http://127.0.0.1:8529")
db = client.db('_system', username='root', password='passwd', verify=True)
if db.has_collection('raw_streams'):
raw_streams = db.collection('raw_streams')
else:
raw_streams = db.create_collection('raw_streams')
raw_streams.insert({"foo": "bar"})
print(list(raw_streams.all())) |
Hi @apetenchea,
My code matches your example and throws the insert error. I'm not connecting to a localhost, maybe that could be part of the problem? |
Document insertion uses If you want to see exactly how the request sent by your driver looks like, you may add the following patch to
To get the location of your package run |
I just tried out bypassing the driver in a few ways: locally on my computer through swaggerHub, which worked flawlessly and through an app running on a separate container, which didn't work. The POST that failed yielded: using { headers: {…}, method: "POST", uri: "http://arango.myHost.com/_db/myDB/_api/document/raw_streams" I tried a GET on the collection it was successful on the container, returning the expected collection properties from the url: http://arango.myHost.com/_db/myDB/_api/collection/raw_streams With the added code in the driver, the insert printed: http://arango.myHost.com/_db/myDB/_api/document/raw_streams, which exactly what I used for testing in swaggerHub and worked successfully. For raw_streams.all() I got: http://arango.myHost.com/_db/myDB/_api/simple/all |
The insert worked successfully from the python driver, or just from swaggerHub? I changed the print statement in the driver code to print slightly more details from the request: print(self._url_prefixes[host_index] + request.endpoint, request.data, request.method, request.params, request.headers) The code I am using to test it is this: from arango import ArangoClient
client = ArangoClient(hosts="http://127.0.0.1:8529")
db = client.db('_system', username='root', password='passwd', verify=True)
db.delete_collection('raw_streams')
if db.has_collection('raw_streams'):
raw_streams = db.collection('raw_streams')
else:
raw_streams = db.create_collection('raw_streams')
raw_streams.insert({"foo": "bar"})
print(list(raw_streams.all())) I am getting the following output:
Does it look similar if you try it? |
The insert did not work on the python driver, but it did on swagger. Also I tried using pyArango, which has been working flawlessly.
I think this may not be an issue with the python-arango and might be something I've got wrong in the DB config. Sorry for the confusion. Do you have any ideas? |
The requests seem to be fine. I can suggest updating the driver, although that shouldn't make much of a difference.
|
Unfortunately and raises the error: If it is a connection error, would you have any idea what it might be? |
It looks like the request has reached some server. |
my gosh, you're right. Sending requests to https fixed the problems 🤦 |
I noticed that calling some methods yield errors:
produces:
`DocumentGetError Traceback (most recent call last)
Cell In[7], line 3
1 raw_streams = db.collection('raw_streams')
2 raw_streams.name
----> 3 raw_streams.all()
File ~\anaconda3\lib\site-packages\arango\collection.py:630, in Collection.all(self, skip, limit)
627 raise DocumentGetError(resp, request)
628 return Cursor(self._conn, resp.body)
--> 630 return self._execute(request, response_handler)
File ~\anaconda3\lib\site-packages\arango\api.py:74, in ApiGroup._execute(self, request, response_handler)
63 def _execute(
64 self, request: Request, response_handler: Callable[[Response], T]
65 ) -> Result[T]:
66 """Execute an API.
67
68 :param request: HTTP request.
(...)
72 :return: API execution result.
73 """
---> 74 return self._executor.execute(request, response_handler)
File ~\anaconda3\lib\site-packages\arango\executor.py:65, in DefaultApiExecutor.execute(self, request, response_handler)
56 """Execute an API request and return the result.
57
58 :param request: HTTP request.
(...)
62 :return: API execution result.
63 """
64 resp = self._conn.send_request(request)
---> 65 return response_handler(resp)
File ~\anaconda3\lib\site-packages\arango\collection.py:627, in Collection.all..response_handler(resp)
625 def response_handler(resp: Response) -> Cursor:
626 if not resp.is_success:
--> 627 raise DocumentGetError(resp, request)
628 return Cursor(self._conn, resp.body)
DocumentGetError: [HTTP 400][ERR 17] expecting string for `
I have similar issues whenever I call a method which makes a request using "/_api/simple/"
Am I doing something wrong? I'm using Arango 3.11.2, python-arango V7.6, python 3.11.3
The text was updated successfully, but these errors were encountered: