0

I am trying to deploy an App Script through the App Script API but keep getting a 404 error - both in the script and the OAuth playground.

Script:

function createNewFile() {
var options,payload,response,theAccessTkn,url, thisID;

thisID = ScriptApp.getScriptId();

theAccessTkn = ScriptApp.getOAuthToken();

url = "https://script.googleapis.com/v1/projects/"+thisID+"/deployments";

payload = {
"versionNumber": 8,
"manifestFileName": "appscript.json",
"description": "oauthtest"
}

options = {
"method" : "POST",
"muteHttpExceptions": true,
"headers": {
   'Authorization': 'Bearer ' +  theAccessTkn
 },
'contentType': 'application/json',
"payload": JSON.stringify(payload)
 };

response = UrlFetchApp.fetch(url,options);

Logger.log(response)

return response;
}

Manifest file:

{
"timeZone": "Africa/Johannesburg",
"dependencies": {
},
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER",
"oauthScopes": ["https://www.googleapis.com/auth/drive", 
"https://www.googleapis.com/auth/script.external_request", 
"https://www.googleapis.com/auth/script.deployments"]
}

Error from log:

[18-12-17 10:31:10:575 SAST] {
"error": {
"code": 404,
"message": "Requested entity was not found.",
"status": "NOT_FOUND"
}
}

Is there some step I still need to do to deploy?

TheMaster
  • 45,448
  • 6
  • 62
  • 85

1 Answers1

0

Possible Issues & Solution:

  • Incorrect manifestFileName: appsscript is the only valid manifest name, at present.
  • Incorrect versionNumber: Version number should be a number of a valid version, that is already saved. Deployment will be based on this version number. To see the available versions, See File>Manage Versions

Code Snippet:

payload = {
"versionNumber": 1,
"manifestFileName": "appsscript",
"description": "oauthtest"
}

Notes:

  • Currently, There's no way to create a new web-app deployment directly from the api.
  • All new deployments projects.deployments.create defaults to execution_api entry point. There's no way to configure the entry point from the api, at present.
  • If there was a valid web-app deployment, You may still be able to create a new version from the latest code using projects.versions.create and update the latest web app deployment to use the latest version(projects.deployments.update). In this case, the web-app entry point, if already present is unchanged, but, defaults to execution api/null, if there was no valid entry point in the deployment, that is updated.

To Read:

TheMaster
  • 45,448
  • 6
  • 62
  • 85