# Error reading string return value in smart contract - java

**URL:** <https://forum.algorand.co/t/error-reading-string-return-value-in-smart-contract-java/10100>\
**Category:** General\
**Tags:** testnet, teal, smart-contracts\
**Created:** [July 31, 2023, 8:22am UTC](https://forum.algorand.co/t/error-reading-string-return-value-in-smart-contract-java/10100 "2023-07-31T08:22:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![francescamartinucci](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/francescamartinucci/32/3656_2.png) [@francescamartinucci](https://forum.algorand.co/u/francescamartinucci)\
**Post date:** [July 31, 2023, 8:22am UTC](https://forum.algorand.co/t/error-reading-string-return-value-in-smart-contract-java/10100/1 "2023-07-31T08:22:20Z")

</div>

Hi guys, i’ve deployed an ABI-compliant smart contract, all its exposed methods return string value in a way like this:

byte 0x151f7c75  
byte “OK”  
concat  
log

I’m trying to read the value from java sdk, but i’m facing an IllegalArgumentException with this message detail: “string decode failure: encoded bytes do not match with length header”.  
Any suggestion?  
Thank you!

---

<div class="post-metadata">

**Author:** ![francescamartinucci](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.algorand.co/francescamartinucci/32/3656_2.png) [@francescamartinucci](https://forum.algorand.co/u/francescamartinucci)\
**Post date:** [August 4, 2023, 9:10am UTC](https://forum.algorand.co/t/error-reading-string-return-value-in-smart-contract-java/10100/2 "2023-08-04T09:10:36Z")

</div>

EDIT: i “solved” the problem in the way as follows:  
In my custom AtomicTransactionComposer class, i add a condition on ABI method parsed return type and simply istantiate a new String from abiEncoded return value:

```auto
ABIType methodRetType = this.methodMap.get(i).returns.parsedType;
if(methodRetType instanceof TypeString) {
	decoded = new String(abiEncoded);
} else {
    decoded = methodRetType.decode(abiEncoded);
}

```
