# Transaction.end generating 401 error

**URL:** <https://discuss.elastic.co/t/transaction-end-generating-401-error/364479>\
**Category:** Elastic Observability\
**Created:** [August 6, 2024, 2:25pm UTC](https://discuss.elastic.co/t/transaction-end-generating-401-error/364479 "2024-08-06T14:25:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantoomey](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@dantoomey](https://discuss.elastic.co/u/dantoomey)\
**Post date:** [August 6, 2024, 2:25pm UTC](https://discuss.elastic.co/t/transaction-end-generating-401-error/364479/1 "2024-08-06T14:25:55Z")

</div>

We have coding that closes the current transaction and creates another. The transaction.end() generates a 401 error: Can't do handshake and publish version of .

Is there any ownership or rights to a transaction that need to be accounted for?

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [August 8, 2024, 12:31pm UTC](https://discuss.elastic.co/t/transaction-end-generating-401-error/364479/2 "2024-08-08T12:31:53Z")

</div>

Hi @dantoomey,

I assume that you are invoking `trasnaction.end()` on one of the [Elastic APM agents](https://www.elastic.co/guide/en/apm/agent/index.html). Can you share which agent (language) you are using and share your code please?

---

<div class="post-metadata">

**Author:** ![dantoomey](https://avatars.discourse-cdn.com/v4/letter/d/b5a626/32.png) [@dantoomey](https://discuss.elastic.co/u/dantoomey)\
**Post date:** [August 8, 2024, 1:33pm UTC](https://discuss.elastic.co/t/transaction-end-generating-401-error/364479/3 "2024-08-08T13:33:25Z")

</div>

Thanks for responding. We are using Java.

Unfortunately, the 401 came about by another simoultaneous task and not from elastic. Sorry
