I have two HTTP requests that produce the same CSV output when I make the requests through the web browser. I have omitted the first part of the URL parameters of both requests since they are the same. It only changes the last parameter that you can see below:
Request A:
https://csv.business.tomtom.com/extern?...[other parameters]...&range_pattern=d-1
Request B:
https://csv.business.tomtom.com/extern?...[other parameters]...&rangefrom_string=01/04/2016 00:00:01&rangeto_string=01/04/2016 23:59:59
CSV output
"start_time","end_time","distance","triptime","operatingtime","standstill","tours","fuel_usage"
"01/04/2016 09:27:39","01/04/2016 17:25:51","293121","15187","28692","2759","4","21.024"
However when I make the requests through the rails app I get an error with Request B. Request A is OK.
Error:
CSV::MalformedCSVError
...
Illegal quoting in line 1.
...
@tripsSummary = CSV.parse(summaryResponse.to_s)
These are the HTTP responses:
Response A
#<HTTP::Response/1.1 200 OK {"Access-Control-Allow-Origin"=>"*", "Access-Control-Allow-Methods"=>"GET", "Access-Control-Max-Age"=>"3600", "Access-Control-Allow-Headers"=>"Origin, X-Requested-With, Content-Type, Accept", "Content-Type"=>"text/comma-separated-values;charset=UTF-8", "Date"=>"Sat, 02 Apr 2016 19:16:04 GMT", "Connection"=>"close", "Transfer-Encoding"=>"chunked"}>
Response B
#<HTTP::Response/1.1 200 OK {"Connection"=>"close", "Cache-Control"=>"no-cache", "Content-Type"=>"text/html; charset=iso-8859-1", "Pragma"=>"no-cache", "Content-Length"=>"108"}>
Questions
- Is request B malformed?
- Why does it work in the browser and it does not work in the app?
- Is there an encoding problem in the parameter rangefrom_string=01/04/2016 00:00:01 ?