ajax - Java POST Connection Timeout Using HttpsUrlConnection -


i have question making post request java, , since first attempt @ of magnitude, please bear me. working on third party application in java connect website , make post requests. doing correctly? here have far:

website code: (this code website has "bumping trade" sends 2 pieces of data php file. url http://cdn.dota2lounge.com/script/trades.js)

function bumptrade(trade, code) { $.ajax({     type: "post",     url: "ajax/bumptrade.php",     data: "trade=" + trade + "&code=" + code }); } 

my java code:

private void sendpost() throws exception {          //string url = "https://www.cdn.dota2lounge.com/script/ajax/bumptrade.php";         string url = "https://www.cdn.dota2lounge.com/script/ajax/bumptrade.php";         url obj = new url(url);         httpsurlconnection con = (httpsurlconnection) obj.openconnection();  //add request header         con.setrequestmethod("post");         con.setrequestproperty("user-agent", user_agent);         con.setrequestproperty("accept-language", "en-us,en;q=0.5");          string urlparameters = "trade=96510389&code=94cebd9";          // send post request         con.setdooutput(true);         dataoutputstream wr = new dataoutputstream(con.getoutputstream());         wr.writebytes(urlparameters);         wr.flush();         wr.close();          int responsecode = con.getresponsecode();         system.out.println("\nsending 'post' request url : " + url);         system.out.println("post parameters : " + urlparameters);         system.out.println("response code : " + responsecode);          bufferedreader in = new bufferedreader(                 new inputstreamreader(con.getinputstream()));         string inputline;         stringbuffer response = new stringbuffer();          while ((inputline = in.readline()) != null) {             response.append(inputline);         }         in.close();          //print result         system.out.println(response.tostring());      } 

however receiving connection timeout error when attempting connect. grateful if point me in right direction!

the java client code seems on right track. looks url in code wrong url.

using url "http://www.dota2lounge.com/ajax/bumptrade.php" , httpurlconnection, able 200 response (ok):

sending 'post' request url : http://www.dota2lounge.com/ajax/bumptrade.php

post parameters : trade=96510389&code=94cebd9

response code : 200

however nothing beyond that. not sure of api of remote site that's help.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -