3

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" } }

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
Hari Das
  • 10,145
  • 7
  • 62
  • 59
  • For future readers - use of the API requires an **API executable** deployment; I had a *web app* deployment and was struggling to understand why I was getting a 404 with this exact same error - until I came across the [requirements section](https://developers.google.com/apps-script/api/how-tos/execute#the_scriptsrun_method) – Janaka Bandara Nov 14 '21 at 07:11

1 Answers1

3

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.

kmanzana
  • 1,138
  • 1
  • 13
  • 23
Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Hey @Tanaike, I'm encountering the same issue, and though I followed your steps to a "T", I am still getting a 404 error when using the `curl` command :( Like the OP, when I "Deploy as API Executable" (Everyone, or Only Me, doesn't matter) my script and set `devMode: false`, the call works. It always returns 404 when using `devMode: true`, regardless of the deploy status. – mxxk Aug 16 '18 at 01:28
  • @mxk I'm really sorry for the inconvenience. When you cannot run the function even if you carried out above flow, your situation might be different from OP's situation. And unfortunately, I couldn't replicate your situation. So can you post it by including the detail information (for example, those are the error message, and the flow you did after a new project was created) as a new question? I think that this will help users think of your solution, and also it will help for users who have the same situation. – Tanaike Aug 16 '18 at 02:10
  • Thanks for your reply @Tanaike. Since posting this, I've tried to reproduce this on both my personal Google account as well as my work Google Apps account, and it seems I have to do more digging, since I was able to call script:run for my work account, even when the script is not deployed as an API executable. Strange! Since my personal account still has this issue. – mxxk Aug 16 '18 at 06:06
  • @mxk Thank you for your additional information. I think that if your situation can be replicated and resolved it, the reason of the issue will be useful information for other users. Also I would like to support about this. – Tanaike Aug 16 '18 at 07:53
  • @Tanaike I have a similar issue but I'm getting the error message when `devMode` is set to `false` (or not set, for that matter). When I make the call with `devMode` as `true` everything works smoothly from both the `curl` and the script calling it. Any ideas? – everspader Jan 28 '21 at 09:33
  • @everspader About your question, I cannot understand it. This is due to my poor skill. I deeply apologize for this. In order to correctly understand your question, can you post your question as new question by including the detail flow for replicating your issue? By this, it will help users including me think of the solution. If you can cooperate to resolve your issue, I'm glad. Can you cooperate to resolve your issue? – Tanaike Jan 28 '21 at 12:45
  • @Tanaike [see this question](https://stackoverflow.com/questions/65773410/google-app-script-message-requested-entity-was-not-found-with-devmode?noredirect=1#comment116557509_65773410) for the complete doubt – everspader Jan 28 '21 at 14:14
  • 1
    @everspader Thank you for your response. I will check it. When I could correctly replicate your situation and understand the issue, I would like to propose an answer. – Tanaike Jan 29 '21 at 00:36