hrrray
hrrray

Reputation: 9

POST request to quora using python requests getting error 400

I am trying to log into Quora using python requests module. I analyzed the website's post request using firebug and following is the data that is sent:

*

json    {"args":[],"kwargs":{"email":"[email protected]","password":"somePassowrd","passwordless":1}}
formkey e50a4be87e84731aea6f9c806957d7d0
postkey df81f33e60422d6bfbe023b35b2e5ba9
window_id   dep3508-955450102918847274
referring_controller    index
referring_action    index
_lm_transaction_id  0.9195199974522774
_lm_window_id   dep3508-955450102918847274
__vcon_json ["hmac","Yg2NGe+k8xotzu"]
__vcon_method   do_login
__e2e_action_id e07kmx186q
js_init {}
-------------------------------------------------
Source :
-------------------------------------------------
json=%7B%22args%22%3A%5B%5D%2C%22kwargs%22%3A%7B%22email%22%3A%22userid%40email.com%22%2C%22password%22%3A%22somePassword%22%2C%22passwordless%22%3A1%7D%7D&formkey=e50a4be87e84731aea6f9c806957d7d0&postkey=df81f33e60422d6bfbe023b35b2e5ba9&window_id=dep3508-955450102918847274&referring_controller=index&referring_action=index&_lm_transaction_id=0.9195199974522774&_lm_window_id=dep3508-955450102918847274&__vcon_json=%5B%22hmac%22%2C%22Yg2NGe%2Bk8xotzu%22%5D&__vcon_method=do_login&__e2e_action_id=e07kmx186q&js_init=%7B%7D

*

I am using the following code to send the request:

  jsonData = {"args":[],"kwargs":{"email":"[email protected]","password":"somePassword","passwordless":1}}
  requestData = { "json":str(jsonData), "formkey":"e50a4be87e84731aea6f9c806957d7d0",
                  "postkey":"401e4ee1aaa3df38f5c869ce0dfd8a58",
                  "window_id":"dep3708-2029720611434364749",
                  "referring_controller":"index",
                  "referring_action":"index",
                  "_lm_transaction_id":0.6156946511223276,
                  "_lm_window_id":"dep3708-2029720611434364749",
                  "__vcon_json":["hmac","Yg2NGe+k8xotzu"],
                  "__vcon_method":"do_login",
                  "__e2e_action_id":"e07ii5e4c3",
                  "js_init":{}
                 }
  s = requests.Session()
  r = s.request( 'POST', URL, data=requestData )

URL is https://www.quora.com/webnode2/server_call_POST?__instart__ But somehow, the response i am getting is Error 400 ( Bad request ). This is obviously because my request is malformed, what am i doing wrong here?!

Upvotes: 1

Views: 347

Answers (0)

Related Questions