You are viewing a single comment's thread from:

RE: SteemJ V0.3.4 has been released ~ Use the Steem API in your Java Project

in #steemdev7 years ago

This piece of code teaching how to create a new transaction is not working anymore:

[...]
Transaction transaction = new Transaction();
// The expiration date defines how long the transaction is valid. This field is optional and SteemJ will automatically use the current system time and an offset.
transaction.setExpirationDate("2016-04-06T08:29:27UTC");
// Define in which block the transaction should be added. In most cases this is the next available block which can be asked using the following lines:
GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties();
int refBlockNum = (globalProperties.getHeadBlockNumber() & 0xFFFF);
transaction.setRefBlockNum(refBlockNum);
transaction.setRefBlockPrefix(globalProperties.getHeadBlockId());
// There is also the option to add extensions to a transaction which are currently not used by Steem and therefore not supported by SteemJ.
// transaction.setExtensions(extensions);

// A Transaction accepts one or more Operations which have to be provided as an ArrayList.
ArrayList<Operation> operations = new ArrayList<>();
[...]
Sort:  

Hay @discernente,

thank you for pointing this out and sorry for the late reply. I've updated the sample at GitHub. The following snippet should work again:

[...]
Transaction transaction = new Transaction();
// The expiration date defines how long the transaction is valid. This field is optional and SteemJ will automatically use the current system time and an offset.
transaction.setExpirationDate("2016-04-06T08:29:27UTC");
// Define in which block the transaction should be added. In most cases this is the next available block which can be asked using the following lines:
GlobalProperties globalProperties = steemApiWrapper.getDynamicGlobalProperties();

transaction.setRefBlockPrefix(globalProperties.getHeadBlockId().getHashValue());
transaction.setRefBlockNum(globalProperties.getHeadBlockId().getNumberFromHash());

// There is also the option to add extensions to a transaction which are currently not used by Steem and therefore not supported by SteemJ.
// transaction.setExtensions(extensions);

// A Transaction accepts one or more Operations which have to be provided as an ArrayList.
ArrayList<Operation> operations = new ArrayList<>();
[...]

Ok, thank you. Now this piece of code is running fine, but I found another error while trying to run the method "getActiveVotes:

Exception in thread "main" eu.bittrade.libs.steemj.exceptions.SteemTransformationException: Could not transform the response into an object.
at eu.bittrade.libs.steemj.communication.CommunicationHandler.performRequest(CommunicationHandler.java:173)
at eu.bittrade.libs.steemj.SteemJ.getActiveVotes(SteemJ.java:311)

Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "author" (class eu.bittrade.libs.steemj.base.models.error.SteemData), not marked as ignorable (8 known properties: "call.method", "posting", "what", "call.params", "type", "name", "id", "api"])
at [Source: (String)"{"id":9,"error":{"code":1,"message":"13 N5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE: unknown key\nunknown key: \n {"author":"discernente","permlink":"https://steemit.com/chart/@discernente/bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener","what":"unknown key"}\n th_a database.cpp:385 get_comment\n\n {"call.method":"call","call.params":["database_api","get_active_votes",["discernente","https://steemit.co"[truncated 1007 chars]; line: 1, column: 976] (through reference chain: eu.bittrade.libs.steemj.base.models.error.SteemError["error"]->eu.bittrade.libs.steemj.base.models.error.SteemErrorDetails["data"]->eu.bittrade.libs.steemj.base.models.error.SteemErrorData["stack"]->java.lang.Object[][0]->eu.bittrade.libs.steemj.base.models.error.SteemStack["data"]->eu.bittrade.libs.steemj.base.models.error.SteemData["author"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:60)
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1148)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1547)

After having a closer look I guess the problem is that you've used the whole link instead of only providing the permlink part. So instead of

https://steemit.com/chart/@discernente/bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener

use:

bitscreener-a-good-cryptocurrencies-free-real-time-charts-screener

ok thank you

Thank you once again - This may be connected to the new Steem version 0.19.2 - I've created #72 at GitHub for this :)