dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
864 stars 467 forks source link

Using dates and date ranges in GET API request #6150

Closed ajwagner777 closed 10 years ago

ajwagner777 commented 10 years ago

I have a project that I am trying to load an initial set of contents, and then load a second page through an AJAX API request. Specifically, I am dealing with an "events" structure, where dates are very important.

I am hitting a roadblock when I am trying to pull contents based on a date. If I search from the admin side, with a date range like this [20140814181700 TO 20991231235959], it returns 12 events (which is expected). However, if I grab the URL form the "Show Query" box and do a test through a testing tool (like Postman for Chrome), it returns nothing, and shows a 400, bad request. If I take out the date part of the query, it works. In addition, if I just search for a specific date, like 20140910*, both on the admin side and through the API, it works. Examples of the URL's being requested are below:

Specific date (with wildcard time): WORKS

http://example.com/api/content/render/false/query/+structureName:SphEvents%20+(conhost:d31dd550-f1f2-4e45-8c41-8e05476f122c%20conhost:SYSTEM_HOST)%20+SphEvents.startTime:20140901*%20+languageId:1*%20+deleted:false%20%20+working:true/orderby/SphEvents.startTime%20desc

Date range: Does not work

http://example.com/api/content/render/false/query/+structureName:SphEvents%20+(conhost:d31dd550-f1f2-4e45-8c41-8e05476f122c%20conhost:SYSTEM_HOST)%20+SphEvents.startTime:%5B20140814181700%20TO%2020991231235959%5D%20+languageId:1*%20+deleted:false%20%20+working:true/orderby/SphEvents.startTime%20desc

Is there anything that I am doing wrong here?

oarrietadotcms commented 10 years ago

Fixed: https://github.com/dotCMS/dotCMS/pull/6172

bryanboza commented 10 years ago

Fixed, tested on nightly build 2014-08-27 // H2 // FF