Prakhar
Prakhar

Reputation: 3536

Using cURL to POST data to a form

I'm trying to use cURL to post data to the form on this URL:

  http://dq.sdc.bsnl.co.in/dq/reversePhone.seam?cid=812363

Seeing its source, the form looks like

<form id="revPhone" name="revPhone" method="post" action="/bsnl-web/reversePhone.seam;jsessionid=D238FA7A23A89A38C56B808B96F5D212" enctype="application/x-www-form-urlencoded" onkeyup="if (!check2(event)) {return false;};A4J.AJAX.Submit('loader2','revPhone',event,{'eventsQueue':'myqueue','parameters':{'revPhone:j_id16':'revPhone:j_id16'} ,'actionUrl':'/bsnl-web/reversePhone.seam;jsessionid=D238FA7A23A89A38C56B808B96F5D212','requestDelay':5} )">

<input type="hidden" name="revPhone" value="revPhone" />
<input type="hidden" name="revPhone:j_id12" />
<input id="revPhone:firstField" type="text" name="revPhone:firstField" maxlength="8" onkeydown="return removeEnter1(event)" />
<input id="revPhone:city" type="text" name="revPhone:city" value="Enter City Name" onblur="defaultText1();hideImage()" onfocus="defaultText2()" onkeyup="showImage(event)" />

Code pasted here: http://hastebin.com/wihunayilu.xml

Trying curl with these values:

curl --data "revPhone:firstField=24988872&revPhone:city=CHENNAI" http://dq.sdc.bsnl.co.in/dq/reversePhone.seam?cid=812363 

I end up with the same page again as a response. How can I see (using firebug?) what parameters are passed to a post form so that I can correctly send the request to the server?

Thanks a lot

Upvotes: 0

Views: 3683

Answers (1)

tterrace
tterrace

Reputation: 1985

The form uses ajax to post to a URL which returns a page with a meta tag redirect. What I did to see the params was submit the form with the debugger open (I used chrome's dev tools, but this may also work in firebug), and then quickly press escape before the call finishes. The params look something like this:

AJAXREQUEST:loader2
revPhone:revPhone
revPhone:j_id12:
revPhone:firstField:24988872
revPhone:city:CHENNAI
revPhone:suggestionBoxId_selection:
javax.faces.ViewState:j_id4
revPhone:search:revPhone:search

and the response is:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta name="Ajax-Response" content="redirect" />
<meta name="Location" content="/bsnl-web/debug.seam;jsessionid=(some JSESSIONID)?cid=877632" />
</head></html>

(I edited out my jsessionid)

My curl line was:

curl --data "AJAXREQUEST=loader2&revPhone:suggestionBoxId_selection=&javax.faces.ViewState=j_id4&revPhone:search=search&revPhone=revPhone&revPhone:j_id12=&revPhone:firstField=24988872&revPhone:city=CHENNAI" http://dq.sdc.bsnl.co.in/dq/reversePhone.seam?cid=812363

Upvotes: 1

Related Questions