0

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

  1. Is request B malformed?
  2. Why does it work in the browser and it does not work in the app?
  3. Is there an encoding problem in the parameter rangefrom_string=01/04/2016 00:00:01 ?

1 Answer 1

1

You should probably escape spaces as %20 in the range_from and range_to params. I don't know how to do that in Ruby, but this question looks like a good start.

The browser probably escapes URLs automatically, which is why you get correct answers there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.