3
votes

While trying to use the query editor in developer console.

"SELECT ID FROM ACCOUNT"

It throws an erorr saying "This session is not valid for use with the REST API".

Any idea what excatly tthe issue here. Earlier it workerd fine. The same problem when i click on "Open" dialog of developer console and select objects.

"CANNOT LOAD OBjects.This session is not valid for use with the REST API"

4

4 Answers

1
votes

I ran into this same issue, where I could open Visualforce pages, Apex, etc but it would give me the error "This session is not valid for use with the REST API" any time I tried to use the Query Editor or create a new Trigger (which needs the object list) via the Developer Console. I tried every browser, flushing cookies, logging in as other users, etc with the same results.

I found that our org has API white listing enabled (https://help.salesforce.com/HTViewHelpDoc?id=security_control_client_access.htm&language=en_US) which blocks the API calls access unless explicitly granted.

From the Salesforce Documentation

"Contact Salesforce to enable API Client Whitelisting. After it’s enabled, all client access is restricted until explicitly allowed by the administrator. This restriction might block access to applications that your users are already using. Before you enable this feature, you should configure and approve connected apps for any client applications you want users to continue using, or give the users a profile or permission set with “Use Any API Client” enabled."

So adding the "Use Any API Client" permission set to your user profile should fix the issue.

To do this via a Permission Set, you can go to Setup > Users > Permission Sets and create a new one. Add a System Permission of 'Use Any API Client'.

There may be a way to enable API access for the Developer Console via whitelisting or the app settings but I was not able to easily find a way. You would definitely want to test whatever functionality you are creating with a user that does not have that permission enabled.

Use Any API client

1
votes

This is happening because of connected app is not configured correctly.

On 'API (Enable OAuth Settings)' panel, move 'Access and manage your data (api)' option from left to right of Selected OAuth Scopes field and then save the setting.

enter image description here

Wait for few minute and then try. It should work.

0
votes

Looks like just the session is expired. Did you try to close developer console, relogin to your SF sandbox and open developer console again?

0
votes

Create a Permission Set, and add a System Permission of 'Use Any API Client'. And associate this permission set to users. It will solve the problem.