How to get the session through a POST

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 repository to be able to save information in the repository?

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: