Trying the REST API with Insomnia REST Client (Session expire or invalid session)

rest-api

GOAL: Use Insomnia REST Client to get data from Salesforce (REST API), in order to implement a server to server solution where I get data (programmatically) from Salesforce without interactively login.

What I have done:

  • configure an App in Salesforce to get a client_id and client_secret
  • Reset security token to use with the username password. password = PASSWORD + SECURITY TOKEN, see below

enter image description here

I am able to get an access_token with 200 OK

enter image description here

Then I use the access_token above to get data by setting Authorization bearer as a header. It fails with Session expired or invalid 401 Unauthorized

Any pointers on what I am doing wrong? or on how to use Insomnia REST client?

enter image description here

Best Answer

Make sure to use the same domain as that is returned in your instance url (my.salesforce.com is what I see from your screenshot) field when you obtained the token.

If you try to use lightning domain it will be unauthorized request.