i want post data http://irsherkat.ssaa.ir/design/searchcompanypublicinfo.aspx value of example 10861677542 #txtnationalcode input. when use fiddler post request http://irsherkat.ssaa.ir/hndlr/generalhandler.ashx?id=33 (which posted data sent to), request header:
content-type: application/x-www-form-urlencoded
and request body:
request={'classtypename':'trm.hndlr.classes.companypublicinfocontroller','methodname':'searchdata','dataparamtype':'trm.hndlr.trmtypedefinition.companypublicinfo.companypublicinfoserchparam','mainentitytype':'','dataparam':'{\'nationalcode\':\'10861677542\',\'registernumber\':\'\',\'unitid\':null,\'companytypeid\':\'0\'}'}
i 200 success result when want c# code:
public async task<string> get() { var request = (httpwebrequest)webrequest.create("http://irsherkat.ssaa.ir/hndlr/generalhandler.ashx?id=33"); var postdata = "request={'classtypename':'trm.hndlr.classes.companypublicinfocontroller','methodname':'searchdata','dataparamtype':'trm.hndlr.trmtypedefinition.companypublicinfo.companypublicinfoserchparam','mainentitytype':'','dataparam':'{\'nationalcode\':\'10861677542\',\'registernumber\':\'\',\'unitid\':null,\'companytypeid\':\'0\'}'}"; var data = encoding.ascii.getbytes(postdata); request.method = "post"; request.contenttype = "application/x-www-form-urlencoded"; request.contentlength = data.length; using (var stream = request.getrequeststream()) { stream.write(data, 0, data.length); } var response = (httpwebresponse)request.getresponse(); return new streamreader(response.getresponsestream()).readtoend(); }
it gives me error:
the remote server returned error: (500) internal server error.
try remove "request="
postdata
value.
Comments
Post a Comment