Fulco
Fulco

Reputation: 284

Python-eve GET response does not contain contents of resource (unless I specify its schema)

I have started using Python-Eve to access an existing MongoDB database I have from another project. I was successful in getting correct HTTP 200 responses for queries to specific documents in the database, but I was puzzled by the fact that they did not contain any information other than the following:

"_items": [
{
  "_updated": "Thu, 01 Jan 1970 00:00:00 GMT",
  "_etag": "<some etag>",
  "_created": "Thu, 01 Jan 1970 00:00:00 GMT",
  "_id": "<some ObjectID>",
}

I have since discovered that I do get the data I want if I specify the entries in a schema in Eve's settings.py file.

I am assuming that this is intended behavior, and that it might have to do something with validation. But I am wondering if there is a way to turn it off. My primary goal was to quickly get a Python REST API up and running for an existing database, specifying the schema is an unnecessary hassle with that goal in mind. I don't mind doing it for now, but I'm just wondering for future applications.

Upvotes: 3

Views: 835

Answers (1)

Nicola Iarocci
Nicola Iarocci

Reputation: 6576

Try setting ALLOW_UNKNOWN to True. Just make sure that your endpoint is read-only, unless you want to allow unknown fields/unvalidated documents in the datastore.

Upvotes: 5

Related Questions