# How to get the session through a POST

**URL:** <https://community.bloomreach.com/t/how-to-get-the-session-through-a-post/2625>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [June 14, 2021, 2:03pm UTC](https://community.bloomreach.com/t/how-to-get-the-session-through-a-post/2625 "2021-06-14T14:03:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asanchez](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@asanchez](https://community.bloomreach.com/u/asanchez)\
**Post date:** [June 14, 2021, 2:03pm UTC](https://community.bloomreach.com/t/how-to-get-the-session-through-a-post/2625/1 "2021-06-14T14:03:02Z")

</div>

Hello,

I comment on the problem. I am sending a json through POST to another environment, from dev to pre, from pre to pro … etc. The question is that with this line:

> threadSafeSession = requestContext.getSession().impersonate(new SimpleCredentials(**requestContext.getSession().getUserID(), new char[0]**));

it gives me the following error:

> **javax.jcr.LoginException: LoginModule could not perform authentication: null**

this in dev I have solved it as follows:

> threadSafeSession = requestContext.getSession().impersonate(new SimpleCredentials( **“admin”, “admin”** ));

but in PRE and PRO we do not have an admin user , how can I get the session with write privileges in the repositor **y to be able to save information in the repository**?

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [June 15, 2021, 12:16pm UTC](https://community.bloomreach.com/t/how-to-get-the-session-through-a-post/2625/2 "2021-06-15T12:16:21Z")

</div>

I think you should try to implement a JAX-RS service with `@Persistable` annotations, and then you don’t need to try to login or impersonate with credentials by yourself, but it’s done automatically by the platform.  
Please see the following:

- HST-2 Plain JAX-RS Service implentation: [RESTful API Support - Plain JAX-RS Services - Bloomreach Experience - Headless Digital Experience Platform](https://documentation.bloomreach.com/14/library/concepts/rest/restful-api-support---plain-jax-rs-services.html)
- Using `@Persistable` annotations in HST-2 Plain JAX-RS Services: [RESTful JAX-RS Component Support - Bloomreach Experience - Headless Digital Experience Platform](https://documentation.bloomreach.com/14/library/concepts/rest/restful-jax-rs-component-support-in-hst-2.html) (See the “@Persistable Annotation Support” section.)
