pythonsalesforcesoql

Salesforce object is not accessible via API, but working via UI


I can access my object by Id via user interface by using URL like lightning/r/Account/0061n00000b5pEdAAI/view, but I'm not able to get it via API with same user:

sf_client.query_all(f"""SELECT Id, Name FROM Account where Id='0061n00000b5pEdAAI'""")

And this happens not with all objects. Like every 3rd object is not available. I checked permissions and set access to all like in this guide:


Solution

  • You're sure you're hitting the same org, same user? Sounds like sandbox where some data was copied over from prod, some is out of sync... Can you go to target org, find that user, scroll down to login history and see logins today, from your Python program (with Application name that can be matched to client id/secret you used in your program)...

    You're using simple salesforce, right? try to grab session id (also known as access token) returned by login call (https://github.com/simple-salesforce/simple-salesforce#readme, scroll down to "Additional Features"). It'll look like 00D0E000000ABCDabc!randomgibberishhere. The part before ! is org id. You can compare it with Setup -> Company Information or (in prod) Setup -> Sandboxes to make sure you're hitting right org. Username would be another giveaway... It's an embarassing mistake if it's really what happened but we've all been there.

    What happens when you run same query in Developer Console (cog/gear icon in upper right corner in UI)?

    What happens when you issue raw REST access or raw query for example with Workbench's REST explorer: https://workbench.developerforce.com/login.php

    /services/data/v58.0/query/?q=SELECT Id, Name FROM Account where Id='0061n00000b5pEdAAI'

    /services/data/v58.0/sobjects/Account/0061n00000b5pEdAAI