Search code examples
google-apps-scriptgoogle-apps-script-api

Apps Script Execution API showing error with devMode: true


Trying to use Execution API for one of my project with devMode: true, but getting the following error. But it works flawlessly when I make devMode: false. NOTE: I am owner and using the API from same account (so it should work ideally)

  1. I have deployed the script as api executable with access as "Anyone"
  2. I have enabled the "Apps Script API" in the developer console
  3. Both the oauth and apps script share the same project

{ "error": { "code": 404, "message": "Requested entity was not found.", "status": "NOT_FOUND" } }


Solution

  • I had also experienced the same situation. So can you confirm the following points again?

    1. Save the apps script using the save button again.
    2. Save the apps script as a new version.
    3. Whether the client ID and client secret are retrieved from the project that Apps Script API is used.
      • Whether the access token is retrieved from these client ID and client secret.
    4. Whether the scope inclues https://www.googleapis.com/auth/drive, https://www.googleapis.com/auth/drive.scripts and https://www.googleapis.com/auth/script.external_request.

    After I confirmed above again, I always test using a following curl command. When you use this curl command, please input your access token, function name and script ID.

    curl -X POST -L \
        -H "Authorization: Bearer ### access token ###" \
        -H "Content-Type: application/json" \
        -d "{function: '### function name ###',devMode: true}" \
        "https://script.googleapis.com/v1/scripts/### script ID ###:run"
    

    In my environment, the error in your question was solved. I don't know whether these can solve your problem. If this was not useful for you, I'm sorry.