search_criteria = {'date':'5/31/2015',
'locations':[{'location_name':'Los Angeles',
'attendees':10,
'services':['Housekeeping','Catering']
},
{'location_name':'New York',
'attendees':5,
'services':['Housekeeping']
}
],
'duration':60
}
What would be a recommended strategy for passing complex query parameters to a RESTful API built with web2py?
Our short term solution has been to provide simple query parameters that can contain delimited values. For example:
GET .../api/available_resources/?date=2015-05-31&locations=Los Angeles|New York&attendees=10|5&services=Housekeeping,Catering|Housekeeping&duration=60
But, this seems less than ideal. It is not intuitive that Los Angeles should be associated with 10 attendees and the two specified services.
Options we have considered include:
- Treating the search criteria as a resource. Thus, we would first POST the complex search criteria and receive a handle in return. Then, we would GET available_resources, passing the search criteria handle. (This seems to be messy regarding how to handle the search criteria. Is it stored statefully in the session? Is it written to the database? When would it get cleaned up?)
- Treat the search as a command. We would POST a resource search command with a JSON representation of the search criteria in the body.
- Implement oData parsing for the query string. (While it is true that oData syntax could be constructed to meet the needs, yikes!, that's a lot of overhead for the API consumer and the API parser.)
Are any of these considered best practice? Or, is there yet another strategy that we could consider?
Many thanks for your help!
Kevin