title: Google App Script - "message": "Requested entity was not found." with devMode = false
body: <p>I am trying to connect my Python script with my project in Google App Script. I have followed all the insctructions in this <a href="https://developers.google.com/apps-script/api/how-tos/execute" rel="nofollow noreferrer">guide</a>.</p>
  <p>I have of course deployed it as an executable API and have tested it with access to only myself, my organization and anyone options.</p>
  <p>When I pass the request with <code>devMode</code> as <code>true</code>, it all works fine. I understand that in this case, it is running the latest saved version. However when I set it to <code>false</code> then I get back the error <code>&quot;message&quot;: &quot;Requested entity was not found.&quot;</code> which as I understand is trying to run the latest deployed version.</p>
  <p>I have also tried going through these questions <a href="https://stackoverflow.com/questions/47892350/apps-script-execution-api-showing-error-with-devmode-true">1</a> and <a href="https://stackoverflow.com/questions/63393159/apps-script-execution-api-404-error-with-devmode-true">2</a> but apparently, the problem they had was the opposite where the script wouldn't run with <code>devMode</code> set to <code>true</code>.</p>
  <p>Everything else seems to be executing correctly but I cannot find the reason why it wouldn't run the script without being on <code>devMode</code></p>
  <p>This is my script:</p>
  <pre class="lang-py prettyprint-override"><code>&quot;&quot;&quot;
  Shows basic usage of the Apps Script API.
  Call the Apps Script API to create a new script project, upload a file to the
  project, and log the script's URL to the user.
  &quot;&quot;&quot;
  from __future__ import print_function
  import pickle
  import os.path
  from googleapiclient import errors
  from googleapiclient.discovery import build
  from google_auth_oauthlib.flow import InstalledAppFlow
  from google.auth.transport.requests import Request
  
  # If modifying these scopes, delete the file token.pickle.
  SCOPES = ['https://www.googleapis.com/auth/script.projects',
            'https://www.googleapis.com/auth/spreadsheets.currentonly'
            ]
  
  SCRIPT_ID = 'someid'
  
  
  def main():
      &quot;&quot;&quot;Calls the Apps Script API.
      &quot;&quot;&quot;
      creds = None
      # The file token.pickle stores the user's access and refresh tokens, and is
      # created automatically when the authorization flow completes for the first
      # time.
      if os.path.exists('token.pickle'):
          with open('token.pickle', 'rb') as token:
              creds = pickle.load(token)
      # If there are no (valid) credentials available, let the user log in.
      if not creds or not creds.valid:
          if creds and creds.expired and creds.refresh_token:
              creds.refresh(Request())
          else:
              flow = InstalledAppFlow.from_client_secrets_file(
                  'credentials.json', SCOPES)
              creds = flow.run_local_server(port=0)
          # Save the credentials for the next run
          with open('token.pickle', 'wb') as token:
              pickle.dump(creds, token)
  
      service = build('script', 'v1', credentials=creds)
  
      # Call the Apps Script API
      try:
          # Create a new project
          request = {'function': 'setData'}
          response = service.scripts().run(body=request,
                                           scriptId=SCRIPT_ID).execute()
  
          print(response)
      except errors.HttpError as error:
          # The API encountered a problem.
          print(error.content)
  
  
  if __name__ == '__main__':
      main()
  </code></pre>