AppEngine app scrpt

101 views
Skip to first unread message

Jakub Mitura

unread,
Dec 17, 2019, 5:51:58 PM12/17/19
to Google App Engine
Hello I want to Connect the app engine to Appscript project but constantly get 

Exception in thread "DefaultDispatcher-worker-1" com.google.api.client.googleapis.json.GoogleJsonResponseException: 404 Not Found
{
  "code" : 404,
  "errors" : [ {
    "domain" : "global",
    "message" : "Requested entity was not found.",
    "reason" : "notFound"
  } ],
  "message" : "Requested entity was not found.",
  "status" : "NOT_FOUND"
}

Generally I proceeded with the tutorial of https://www.raywenderlich.com/4656683-build-an-api-with-kotlin-on-google-cloud-platform to set up a project , and the part of authenticating to connect to google sheet and display it works fine - so basic authenthication works than I set upsome modifications to be able to connect to App script files on my google account 

first I added new scopes - the same as I have on my oauth2 cloud console set by function

object AppCredentials {
 val
local: HttpRequestInitializer by lazy {
 
HttpCredentialsAdapter(GoogleCredentials.fromStream(pathStream).createScoped(scopes))
 
}

 
private val pathStream
 
get() = AppCredentials::class.java.getResourceAsStream(credentialsFilePath)
 
?: error("Resource not found: $credentialsFilePath")

 
private val scopes by lazy {var res = arrayListOf<String>()
 
// res.addAll(SheetsScopes.all())
 res
.addAll(createListOfScopesStrings())
 res
 
}
 init
{

 
}
}
/**gets Strings of scopes that we are intrested in*/
private fun createListOfScopesStrings(): ArrayList<String> {
 val res
= ArrayList<String>()
// res.addAll(ScriptScopes.all())
 res
.addAll(
 arrayListOf
(
 
ClassroomScopes.CLASSROOM_ANNOUNCEMENTS,
 
ClassroomScopes.CLASSROOM_COURSES,
 
ClassroomScopes.CLASSROOM_COURSEWORK_ME,
 
ClassroomScopes.CLASSROOM_COURSEWORK_STUDENTS,
 
ClassroomScopes.CLASSROOM_GUARDIANLINKS_STUDENTS
 
,
 
ClassroomScopes.CLASSROOM_PROFILE_EMAILS,
 
ClassroomScopes.CLASSROOM_PUSH_NOTIFICATIONS,
 
ClassroomScopes.CLASSROOM_ROSTERS,
 
ClassroomScopes.CLASSROOM_TOPICS,
 
ClassroomScopes.CLASSROOM_STUDENT_SUBMISSIONS_STUDENTS_READONLY
 
)
 
)
 res
.addAll(DriveScopes.all())
 res
.addAll(CalendarScopes.all())
 res
.addAll(SheetsScopes.all())
 res
.addAll(ScriptScopes.all())

 
return res
}
private const val credentialsFilePath = "/credential.json"





I deployed them as api executables and set the possibility of access to anyone. After setting up some methods I changed the version .
I copied the script id  and tried to connect by code as presented below

val scriptId = "MiTs599IhwfuT-yilc1N31_ZQHuFeqzZk"
// val scriptId = "Mqk0beL1sHumqKnvww4rMsvZQHuFeqzZk"
// 1
private val transport = GoogleNetHttpTransport.newTrustedTransport()
// 2
private val jacksonFactory = JacksonFactory.getDefaultInstance()
// 3
private val scriptService = Script.Builder(transport, jacksonFactory, AppCredentials.local).build()
val request = ExecutionRequest()
request.setFunction("setBasicStudentDataFromFilledFormsTop")

The script Id and function name is ok i checked it couple times, so Why it is not connecting? 
I will greatly appriciate help ! 

Elliott (Cloud Platform Support)

unread,
Dec 19, 2019, 11:01:19 PM12/19/19
to Google App Engine
Hello Jakub,

Please note that Google Groups are reserved for general Google Cloud Platform and product discussions and not for technical issues, which is why I suggest moving the troubleshooting to Stackoverflow, where you may receive advice from our programming community.


Jakub Mitura

unread,
Dec 22, 2019, 5:47:11 PM12/22/19
to Google App Engine
Ok thanks !
Reply all
Reply to author
Forward
0 new messages