# Fetching transaction details in expres

**URL:** <https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324>\
**Category:** Uncategorized\
**Created:** [March 23, 2022, 11:00am UTC](https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324 "2022-03-23T11:00:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bisht](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bisht](https://forum.algorand.co/u/bisht)\
**Post date:** [March 23, 2022, 11:00am UTC](https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324/1 "2022-03-23T11:00:51Z")

</div>

I am creating rest api where i will get withdraw txn but when I am getting different format in console and postman app. Refer the screenshot.How shall I manage it?

 ![Screenshot from 2022-03-23 16-30-03](https://us1.discourse-cdn.com/flex016/uploads/algorand/original/2X/e/e4ba6c6fee6053a809ecde4dcbe37ed3c1ad2b1a.png)  
 ![Screenshot from 2022-03-23 16-29-56](https://us1.discourse-cdn.com/flex016/uploads/algorand/original/2X/6/6f0d204c79bbc775f49bb884f7b6eab8bf3d4629.png)  
s

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [March 23, 2022, 2:36pm UTC](https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324/2 "2022-03-23T14:36:39Z")

</div>

The transaction object you’re trying to send is an object with byte arrays inside `Uint8Array`.  
It looks like you’re trying to serialize it into JSON.  
This will cause issues as JSON does not support byte arrays.

Instead, we strongly recommend to serialize transactions in msgpack, which is how all transactions on Algorand are serialized.  
If you need the REST API to output a JSON object, you can do for example:

```auto
{
   "transaction": <base64 of the msgpack encoding>
}

```

See how for example ARC-1 serializes transactions:

> <https://github.com/algorandfoundation/ARCs/blob/main/ARCs/arc-0001.md#sign-a-group-of-two-transactions>

```nohighlight
const txn1B64 = Buffer.from(txn1.toByte()).toString("base64");

```

assuming `txn1` is the transaction you want.  
`txn1B64` is then what you want your REST API to return.

---

<div class="post-metadata">

**Author:** ![bisht](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@bisht](https://forum.algorand.co/u/bisht)\
**Post date:** [March 24, 2022, 11:46am UTC](https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324/3 "2022-03-24T11:46:52Z")

</div>

I will be using rest api so shall i follow approach

1. const txn1B64 = Buffer.from(txn1.toByte()).toString(“base64”);
2. const encodedtxn = algosdk.encodeUnsignedTransaction(txn)

which one shall i prefer?

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [March 24, 2022, 1:08pm UTC](https://forum.algorand.co/t/fetching-transaction-details-in-expres/6324/4 "2022-03-24T13:08:33Z")

</div>

`txn1.toByte()` is equivalent to `algosdk.encodeUnsignedTransaction(txn1)`  
You still need to convert to Base64 in the second case:

```nohighlight
const encodedtxn = Buffer.from(algosdk.encodeUnsignedTransaction(txn)).toString("base64");

```
