Pages:
Author

Topic: . - page 55. (Read 491783 times)

hero member
Activity: 575
Merit: 502
July 23, 2015, 07:32:54 AM
To anyone here who's got a snippet of Java code that successfully uses the API to place/cancel an order: could you share the code that you used to make a successful POST request? I've been writing a bot that accesses the API info via GET requests with no trouble, but I've been stymied with the POST requests. The Java code I'm using shoots me back this API error code:

Code:
{"errorDescription":"Incorrect request","errorCode":1}

And this is the method code that produces the above error. (A Java whiz will recognize it as ripped-off code to POST to a form page, which is what it is  Embarrassed ):

Code:
  private static String HTTPPost(String ApiChoice, String params) {
    String output;
    int responseCode;
    String urlString;
    URL url;
    URLConnection urlconnection;
    HttpURLConnection connection;
    DataOutputStream out;
    BufferedReader in;
    String whoops;
    int i;

    output = "Wrong crypto parameter!";
    if(ApiChoice.equals("nxt")) {
      urlString = NxtApiLoc + "/nxt";
    }
    else if(ApiChoice.equals("nhz")) {
      urlString = HZApiLoc + "/nhz";
    }
    else return output;

// Might need to add an ? after /nxt and /nhz.

    output = "";

    try{
      url = new URL(urlString);
      urlconnection = url.openConnection();
      connection = (HttpURLConnection)urlconnection;
      connection.setRequestMethod("POST");
      connection.setRequestProperty("charset", "utf-8");
      connection.setRequestProperty("Content-Type",
           "application/x-www-form-urlencoded");
      connection.setRequestProperty("Content-Language", "en-US");
      connection.setUseCaches (false);
      connection.setDoInput(true);
      connection.setDoOutput(true);

      out = new DataOutputStream(connection.getOutputStream());
      out.writeBytes(params);
      out.flush();
      out.close();

      responseCode = connection.getResponseCode();
      in = new BufferedReader(new InputStreamReader(connection.getInputStream()));            
      output = in.readLine();

/*
Might want to try this approach:

      StringBuffer fetcher = new StringBuffer();
      while ((output = in.readLine()) != null) {
        fetcher.append(inputLine);
      }
      in.close();
      output = fetcher.toString();

*/

    } catch(IOException ex) { output = "Failed"; };
    return output;
  }  

Anyhoo, I'm not trying to turn this thread into Stack Exchange: I just clipboarded this code to show you what I'm trying to do.

If there's anyone here that has a method that successfully makes a POST request to the API, I'd be grateful if you could share how you did it. Thanks!

The NFD NSC Asset transfer tool used post requests:

https://bitbucket.org/NFDcoin/nfdcoin/src/98e60e67f1df0e073862c787fda7312f3eba85b1/src/java/nfd/util/NSCAssets/APIRequest.java?at=NFD-1.2.9#APIRequest.java-54

Example to use the sendRequest method.
https://bitbucket.org/NFDcoin/nfdcoin/src/98e60e67f1df0e073862c787fda7312f3eba85b1/src/java/nfd/util/NSCAssets/NSCAssetTransfer.java?at=NFD-1.2.9#NSCAssetTransfer.java-149
Code:
StringBuffer url = new StringBuffer();
url.append((isHttpsConnection ? "https" : "http"));
url.append("://localhost:");
url.append((isTestnet ? "9876" : Nxt.getIntProperty("nxt.apiServerPort")));
url.append("/nxt?requestType=transferAsset");
url.append("&secretPhrase=" + secret);
url.append("&comment=" + transferMessage.getMessage());
url.append("&recipient=" + Convert.toUnsignedLong(generatorAccount.getAccountId()));
url.append("&asset=" + NSC_ASSET_ID);
url.append("&quantityQNT=" + transferMessage.getQuantity());
url.append("&feeNQT=100000000&deadline=100");

StringBuffer buffer;
if (!isDryRun) {
buffer = APIRequest.sendRequest(url.toString());
} else {
buffer = new StringBuffer("mode --dry-run: sending of transactions is disabled");
}
legendary
Activity: 924
Merit: 1000
July 23, 2015, 06:32:57 AM
EDIT: It turns out I was barking up the wrong tree; the POST method I have does work. My call just got hung up because of a silly mistake I made due to my ignorance of how Java regex works. After I caught it, my POST requests have now gone through successfully.

Note To Would-Be Programmers (Like Me): Sometimes, just asking for help frees up your mind enough to think outside the rut you're spinning your wheels in. Smiley
legendary
Activity: 902
Merit: 1001
Free trial of #AltFolio = save time, react faster
July 21, 2015, 05:53:46 PM
Hi. I was wondering if we could see some of the HZ assets listed on coinmarketcap.com? I think that would be a great step.
I notice that coinmarketcap uses https://trade.secureae.com for it's data on NXT assets, is there an equivalent data source for HZ?

Thanks for all the great efforts with HZ lately Smiley

cryptoassetcharts.info is listing them all
(even though the spheres picture is not uptodate, just told him).

And with a dedicated page for each asset, e.g.: AAssetHZ

sr. member
Activity: 355
Merit: 250
July 21, 2015, 07:26:48 AM
Yes i update peer list and everything is ok now.
full member
Activity: 199
Merit: 102
July 21, 2015, 05:38:08 AM
there is some problem with downloading blocks from scratch in 3.9.2. Nhz server started successfully but stuck in block downloading. Please fix it.

You could also check if you have no peers, as was my problem since I was reusing an old nhz-default.properties file (if that's the case, see above in recent posts).
member
Activity: 80
Merit: 10
July 21, 2015, 05:27:40 AM
there is some problem with downloading blocks from scratch in 3.9.2. Nhz server started successfully but stuck in block downloading. Please fix it.


worked fine for me did hang for a little while i just left it on overnight and it was done in the morning

go over to the horizon forum and ask around  or maybe someone here might know more.
legendary
Activity: 971
Merit: 1000
July 21, 2015, 01:08:39 AM
Hi. I was wondering if we could see some of the HZ assets listed on coinmarketcap.com? I think that would be a great step.
I notice that coinmarketcap uses https://trade.secureae.com for it's data on NXT assets, is there an equivalent data source for HZ?

Thanks for all the great efforts with HZ lately Smiley

Right now it is the asset issuers responsibility to contact coinmarketcap to have their asset listed on there.
sr. member
Activity: 355
Merit: 250
July 21, 2015, 01:07:28 AM
there is some problem with downloading blocks from scratch in 3.9.2. Nhz server started successfully but stuck in block downloading. Please fix it.
full member
Activity: 199
Merit: 102
July 20, 2015, 10:19:32 PM
Hi. I was wondering if we could see some of the HZ assets listed on coinmarketcap.com? I think that would be a great step.
I notice that coinmarketcap uses https://trade.secureae.com for it's data on NXT assets, is there an equivalent data source for HZ?

Thanks for all the great efforts with HZ lately Smiley
sr. member
Activity: 392
Merit: 250
my magic is growing strong[er]
July 20, 2015, 05:26:49 PM
A powerful (old yet) new concept is taking root. Check it out at https://explorer.horizonplatform.io/?page=asset&id=1918076501414611727
sr. member
Activity: 423
Merit: 250
sr. member
Activity: 355
Merit: 250
July 20, 2015, 07:20:29 AM
Hello what is deadline to update nodes to version 3.9.2 ? Which block or date (time) ?
legendary
Activity: 966
Merit: 1001
July 20, 2015, 06:21:41 AM
Vote for hz to get on cryptsy!
legendary
Activity: 902
Merit: 1001
Free trial of #AltFolio = save time, react faster
sr. member
Activity: 423
Merit: 250
July 20, 2015, 05:45:50 AM
Cryptsy hasn't added new coins since a while. We're in contact with them already.
legendary
Activity: 1960
Merit: 1010
July 20, 2015, 05:37:47 AM
I just saw HZ on voting list on Cryptsy.

Would be nice to get on cryptsy! I think HZ is doing extremely well with development, price will soon reflect this I guess Smiley

Definately needs to go to Cryptsy, a big solid exchange. Horizon has been in the votelist for ages but no one seems to use it.
It will take donations and/or a big giveaway to get the numbers up. It's possible on bitcoingarden forum.
http://bitcoingarden.tk/forum/index.php?board=2.0
legendary
Activity: 1946
Merit: 1007
July 20, 2015, 05:32:11 AM
I just saw HZ on voting list on Cryptsy.

Would be nice to get on cryptsy! I think HZ is doing extremely well with development, price will soon reflect this I guess Smiley
legendary
Activity: 938
Merit: 1000
July 18, 2015, 08:58:27 PM
I just saw HZ on voting list on Cryptsy.
newbie
Activity: 44
Merit: 0
July 18, 2015, 09:08:40 AM
Upgraded to V3.9.2 on Win7 and hallmarked node promptly detected. Nice!

All looks good however wallet contacts are gone.  Anyway to restore wallet contacts without re-typing them in?

A standalone client capable of one-click updates might do the magic. I don't know if its on the works though.

Googling-around I learned the wallet contacts are buried in the bowels of the browser profile (I didn't realize when my contacts went missing I had used a different Chrome profile to setup the contacts)
http://bitcoin.stackexchange.com/questions/30443/in-nxt-which-files-store-the-contact-addressbook-data

Although I do like the one-click idea for updating the wallet, sort of like I've been doing with NXT by having the new zip overwrite everything (and now understand the importance of keeping custom configs out of the default config files).
https://bitcointalksearch.org/topic/m.11893293
jr. member
Activity: 51
Merit: 10
July 17, 2015, 11:42:24 PM
Developers. I use test version HZ v4.0 in Firefox. After changing the language to Russian is not possible to go into the purse second time, no longer displays the authorization form. Only helps complete cleaning browser history, but after the change of the language is the same again. Please correct before release HZ v4.0

Fuck 4.0. See https://bitcointalksearch.org/topic/m.11888906
Pages:
Jump to: