I am having trouble with the list
type in my schemas. Whenever I try to POST, I get a 422 response stating 'must be of list type'. Below is a simple example that produces this problem.
from eve import Eve
people = {
'schema': {
'tests': {
'type': 'list',
'schema': {
'type': 'string'
},
'required': True,
}
},
'resource_methods': ['GET', 'POST'],
}
settings = {
'DOMAIN': {
'people': people
}
}
app = Eve(settings=settings)
if __name__ == '__main__':
app.run()
Then when you POST to the people endpoint with the following:
import requests
url = "http://localhost:5000/people"
person = {
"tests": ['a', 'b'],
}
r = requests.post(url, data=person)
print(r.json())
You get the 422 response. When I debug this, it looks like the Eve application has received the tests
parameter as just a string, 'a'
, rather than the whole list. From what I can see in the Eve tests on GitHub, this seems to be the right way to make the request, so I can only assume I'm making a mistake in setting up the resource/schema?
Thanks.