Open aetherknight opened 7 years ago
To clarify further, there are 2 problems:
I ran into the same problem today. I put a log message into protorpc util.py to see what was being passed to the decoded_datetime function, and it's a dictionary with the milliseconds
and time_zone_offset
arguments as keys. Of course, that method expects a string argument.
Endpoints and/or protorpc triggers a 500 error if a DateTime field is used as a query parameter instead of in the body of a request.
Reference Code
DateTime in a JSON body works as expected
When the
post
method is called with the date time in the JSON body in an ISO 8601-like format, it works fine:DateTime as a query parameter generates erroneous APIs Explorer UI that causes 500s
However, when a datetime is in a query parameter, the endpoints API specification tells APIs explorer to show the fields that make up the DateTimeField type instead of a single string field:
If I try to supply what I would think is a valid DateTime in milliseconds since the epoch and timezone offset, I get a 500 error:
Note: Locally on the dev_appserver and both endpoints 1 and endpoints-2.0.2, if I send the query without using the fields from APIs Explorer, then it works as expected. Eg, the URL
http://localhost:8080/_ah/api/someapi/v1/get?query_date=2017-01-01T00:00:00
responds with a 204 (and it prints the supplied date).When deployed to appengine with endpoints 1, trying to submit a string to the query_date directly causes a 500 that does not show up in my logs. I have not tested endpoints 2 when deployed yet.
Expected Behavior
the endpoints API description provided to APIs Explorer should expose a datetime query parameter as a string field, the same way it does when a datetime field is in the body.