RSocrata icon indicating copy to clipboard operation
RSocrata copied to clipboard

400 Bad request on group by query

Open geneorama opened this issue 6 years ago • 1 comments

q <- paste0("https://data.cityofchicago.org/resource/m6dm-c72p.json?",
            "$select=date_extract_y(trip_start_timestamp),",
            "date_extract_m(trip_start_timestamp),",
            "date_extract_d(trip_start_timestamp),",
            "count(trip_start_timestamp)&",
            "$group=date_extract_y(trip_start_timestamp),",
            "date_extract_m(trip_start_timestamp),",
            "date_extract_d(trip_start_timestamp)")
tab <- RSocrata::read.socrata(q)

results in

> tab <- RSocrata::read.socrata(q)
2019-05-23 09:15:00.397 getResponse: Error in httr GET: 400  https://data.cityofchicago.org/resource/m6dm-c72p.json?%24select=date_extract_y%28trip_start_timestamp%29%2Cdate_extract_m%28trip_start_timestamp%29%2Cdate_extract_d%28trip_start_timestamp%29%2Ccount%28trip_start_timestamp%29&%24group=date_extract_y%28trip_start_timestamp%29%2Cdate_extract_m%28trip_start_timestamp%29%2Cdate_extract_d%28trip_start_timestamp%29&$order=:id
Error in getResponse(validUrl, email, password) : Bad Request (HTTP 400).

This is my first time noticing the end of the query (the order=:id part), this is probably the issue. (before it was off the screen and I didn't see it!)

geneorama avatar May 23 '19 14:05 geneorama

This works, and can be used to check the expected output: jsonlite::fromJSON(readLines(q))

geneorama avatar May 24 '19 15:05 geneorama