0

Is there any way to get session id of a user so that I want to use it in REST API call in Postman to view the response. When I do the api call using my session id, we are recieving invalid user information in the response. We do not have any credentials of the user to get the session id of that user by logging in. Please suggest

2 Answers 2

1

We do not have any credentials of the user to get the session id of that user by logging in

If that’s the case, then you cannot call any APIs. That’s not how APIs or any other services work. If you want to invoke an API, you will need to utilize a User credential here.

Remember to be able to call a REST API, you will need an auth token. And if you cannot authenticate a User at first place because it is never setup in Salesforce, you cannot ever get the auth token.

Take a look at Understanding Authentication to understand how it works in context of REST API. As for Session Id that you are using in POSTMAN, you will need to ensure that it’s still active and not expired.

0

You mean just for debugging purposes?

You could create a Visualforce page with {!$Api.Session_ID} syntax in it, view it as the user in question, and you'll have a session ID representing them. Use that in your REST API testing. I would suggest though that you not leave this page in place for longer than it needs to be there, because leaving users' Session IDs dangling in the wind is a security risk.

3
  • Thanks Charles but how can I use the user in that syntax to get the session Id? Do I need to pass the user id in the controller or do I need to login as that user? If that is the case, I do not have credentials of the user. Please suggest
    – S kanth
    Apr 21, 2019 at 16:35
  • I believe it is login as feature: help.salesforce.com/…
    – tugce
    Apr 21, 2019 at 18:47
  • Yes you can do a Login As and then nab their session ID.
    – Charles T
    Apr 21, 2019 at 21:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .