<p><a href="https://cardano.stackexchange.com/questions/7714/how-to-query-the-chain-index-tx-endpoint/7734#7734">how to query the chain index tx endpoint?</a></p>
<p>I think you are probably still seeing this.
This happens on a number of the apis.
Shame swagger doesn't return the actual error. It would save some time.</p>

CC BY-SA 4.0
2022-05-22T02:07:20.370Z
I changed the object in the payload and got a response, not the one I expected though. I have added the info as updates to the question.
lambda
CC BY-SA 4.0
2022-05-22T11:20:46.520Z
the chain-index is such a headache that I gave up. Bon courage.
waalge
CC BY-SA 4.0
2022-05-21T15:38:55.057Z
2022-05-21T15:38:55.057Z
waalge
<p>Hitting the chain index endpoint to query utxo just gives <code>Bad Request</code> as response.
Tried this on testnet where <code>txOutRefId</code> is the <code>tx hash</code> of a testnet transaction. Screenshot is attached.</p>
<pre><code>curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  &quot;txOutRefId&quot;: &quot;32178b5f5af6c2ac963adef07284f35cb7a86ff1cdd18e119007631607a28b84&quot;,
  &quot;txOutRefIdx&quot;: 0
}'
</code></pre>
<p><a href="https://i.sstatic.net/S9Q7A.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/S9Q7A.png" alt="enter image description here" /></a></p>
<p>Unable to figure out what I am doing wrong here. Has anyone been able to use this endpoint?</p>
<p>Note: Chain index is synced and <code>/tip</code> endpoint works.</p>
<p><em><strong>Update:</strong></em>
This seems to be required format for the endpoint</p>
<pre><code>curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  &quot;txOutRefId&quot;: {&quot;getTxId&quot;:&quot;3961a841f5af32d3878cd816a23c9da7b3c3bb586e3b3db5fba1579bd1408a20&quot;},
  &quot;txOutRefIdx&quot;: 0
}'

</code></pre>
<p>Howeve my chain-index responded with this</p>
<pre><code>Delete your chain index database and resync.
CallStack (from HasCallStack):
  error, called at src/Plutus/ChainIndex/DbSchema.hs:232:22 in plutus-chain-index-core-0.1.0.0-inplace:Plutus.ChainIndex.DbSchema
</code></pre>
<p>Beats me why it asks for a resync. Resyncing chain index will take days, so I have not gone ahead to try that :)</p>

CC BY-SA 4.0
2022-05-21T08:29:51.277Z
What error does curl return when run in the terminal?
waalge
CC BY-SA 4.0
2022-05-21T08:44:13.313Z
@waalge: Thanks for that comment. Terminal gives. 
Error in $.txOutRefId: parsing Plutus.V1.Ledger.TxId.TxId(TxId) failed, expected Object, but encountered String

Seems it expects the TxId object defined in Plutus as TxId { getTxId :: PlutusTx.BuiltinByteString }. 
Will try it out
lambda
<chain-index>
Using chain-index endpoints
# Using chain-index endpoints

(Asked by: username_0 on 2022-05-21)

Hitting the chain index endpoint to query utxo just gives Bad Request as response.
Tried this on testnet where txOutRefId is the tx hash of a testnet transaction. Screenshot is attached.
curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  "txOutRefId": "32178b5f5af6c2ac963adef07284f35cb7a86ff1cdd18e119007631607a28b84",
  "txOutRefIdx": 0
}'


Unable to figure out what I am doing wrong here. Has anyone been able to use this endpoint?
Note: Chain index is synced and /tip endpoint works.
Update:
This seems to be required format for the endpoint
curl -X 'POST' \
  'http://localhost:9083/unspent-tx-out' \
  -H 'accept: application/json;charset=utf-8' \
  -H 'Content-Type: application/json;charset=utf-8' \
  -d '{
  "txOutRefId": {"getTxId":"3961a841f5af32d3878cd816a23c9da7b3c3bb586e3b3db5fba1579bd1408a20"},
  "txOutRefIdx": 0
}'


Howeve my chain-index responded with this
Delete your chain index database and resync.
CallStack (from HasCallStack):
  error, called at src/Plutus/ChainIndex/DbSchema.hs:232:22 in plutus-chain-index-core-0.1.0.0-inplace:Plutus.ChainIndex.DbSchema

Beats me why it asks for a resync. Resyncing chain index will take days, so I have not gone ahead to try that :)

**Tags:** chain-index
> **Comments:**
> **username_1**: What error does curl return when run in the terminal?  
> **username_0**: @waalge: Thanks for that comment. Terminal gives.  Error in $.txOutRefId: parsing Plutus.V1.Ledger.TxId.TxId(TxId) failed, expected Object, but encountered String  Seems it expects the TxId object defined in Plutus as TxId { getTxId :: PlutusTx.BuiltinByteString }.  Will try it out  

---

## 1 answers

### Answer by username_1 on 2022-05-21. Score: 0

[how to query the chain index tx endpoint?](https://cardano.stackexchange.com/questions/7714/how-to-query-the-chain-index-tx-endpoint/7734#7734)

I think you are probably still seeing this.
This happens on a number of the apis.
Shame swagger doesn't return the actual error. It would save some time.

> **Comments:**
> **username_0**: I changed the object in the payload and got a response, not the one I expected though. I have added the info as updates to the question.  
> **username_1**: the chain-index is such a headache that I gave up. Bon courage.  

---

