I'm trying to use the following code from the google docs API from within google apps script for testing purposes:
var f = UrlFetchApp.fetch("https://docs.googleapis.com/v1/documents/1ys6KIY1XOhPHrgQBJ4XxR1WDl0etZdmR9R48h2sP2cc:batchUpdate", {
method:"post",
body: JSON.stringify({
"requests": [
{
"deleteContentRange": {
"range": {
"startIndex": 1,
"endIndex": 80
}
}
}
]
}),
headers: {
Authorization:"Bearer " + ScriptApp.getOAuthToken(),
"Content-Type": "application/json"
}
})
Logger.log(f)
(Also, when I try this in the browser manually entering in the oauth token, same result as below); however, I get an error:
{
"error": {
"code": 403,
"message": "Google Docs API has not been used in project 861341326257 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/docs.googleapis.com/overview?project=861341326257 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
"status": "PERMISSION_DENIED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console API activation",
"url": "https://console.developers.google.com/apis/api/docs.googleapis.com/overview?project=861341326257"
}
]
}
]
}
}
even though I can use the DocumentApp from within google apps script, which is seemingly the same thing (or is it)?
Anyway, when I go to that link its an error (expectedly), since there is no real "project" to activate, as the google apps script does a lot of behind the scenes stuff to make the api work.
So how can I bypass this error in google apps script? My manifest file reads like this BTW:
{
"timeZone": "America/New_York",
"dependencies": {
},
"oauthScopes": [
"https://www.googleapis.com/auth/documents",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/script.external_request"
],
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
So I think the scope is included.
Any ideas?