404 error when deploying a Google Apps script via the REST API

血红的双手。 提交于 2019-12-08 09:38:18

问题


I'm trying to deploy a Google Apps script via the Google REST API, and I'm using the API Explorer to perform that.

This is the method I am testing: https://developers.google.com/apps-script/api/reference/rest/v1/projects.deployments/create

Executing the method via the API Explorer returns a 404 error. I have verified that the scriptId in question does exist, and have tried several other scriptIds, to no avail. I have also made sure the permission scopes are properly set.

This is what the API Explorer gives me.

Worth mentioning that the same scriptId works when calling another method such as projects.get.

Is there anything I am missing, or is this an issue on Google's end? In case of the latter, what are the steps to contact Google Apps Script's team and inform them of this issue?


回答1:


Your versionNumber is incorrect. The Requested entity here refers to the version of your script. You need to go to File>Manage Versions>Save New version to create a new version(or create one with the api1) and use that version number in the request body.




回答2:


Check your authorization scopes. You need to have the following scope enabled:

https://www.googleapis.com/auth/script.deployments

If its not in the list of available scopes in API Explorer then you'll need to add it manually (there is an area at the bottom of the authorization dialog where you can add scopes).

Google's API Explorer uses API keys to authorize requests. In some cases an API key is not sufficient and an OAuth2 (bearer) access token is required. As an alternative you can create an Apps Script project and add the appropriate scopes via the manifest file(appsscript.json). Then you can use UrlFetchApp.fetch() to test the API directly.



来源:https://stackoverflow.com/questions/55453933/404-error-when-deploying-a-google-apps-script-via-the-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!