-2

I want to make a complex query to a Flask-Restless api using Requests. I am not sure how to build the following query from the examples with Requests. How do I make this query?

GET /api/person?q={"filters":[{"name":"age","op":"ge","val":10}]} HTTP/1.1
Host: example.com
davidism
  • 121,510
  • 29
  • 395
  • 339

1 Answers1

0

Flask-Restless expects a query string in JSON format. The example given is a dictionary with a list of filters, each filter being another dictionary. Build your query structure, dump it to JSON, then make the query with Requests.

import json
q = {'filters': [{'name': 'age', 'op': 'ge', 'val': 10}]}
r = requests.get('http://example.com', params={'q': json.dumps(q)})
davidism
  • 121,510
  • 29
  • 395
  • 339