jcollum
jcollum

Reputation: 46609

how should I re-create a POST first seen in Fiddler in Ruby?

This seemed pretty straightforward:

And yet. Every time I run the post, it gets a 500. Could really use a suggestion here.

Original POST (Raw):

POST http://www.example.com/products/ajax HTTP/1.1
Host: www.example.com
Connection: keep-alive
Content-Length: 154
Origin: http://www.example.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19
Content-Type: application/x-www-form-urlencoded
Accept: application/json, text/javascript, */*; q=0.01
Referer: http://www.example.com/products
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

q=getProducts&page=52&type=leaf_blowers

But when I get this in the Rails console:

>> res = http.post_form URI.parse(the_url), {'a' => 'getProducts', 'page'=> '52', 'type'=> 'leaf_blowers'}
=> #<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>

The first one (Fiddler) results in HTML being returned. The second is just a 500 error. Is there anything obvious that I'm missing here? If you'd like to see the Wireshark capture, let me know how I can get it to look like the Fiddler raw capture -- I can't figure out how to get that detail out of Wireshark.

Upvotes: 1

Views: 567

Answers (1)

luis.parravicini
luis.parravicini

Reputation: 1227

Maybe it's a typo when you posted the question, but the original post has

q=getProducts

and then you make the request with:

'a' => 'getProducts'

What happens if you make the request with 'q' => 'getProducts' ?

Upvotes: 1

Related Questions