Google App-Script call functions from service - google-apps-script

When accessing functions on google appScript from java code using a service account i get an error of:
Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal error encountered.",
"reason" : "backendError"
} ],
"message" : "Internal error encountered.",
"status" : "INTERNAL"
}
The same this happens from app-engine with default credentials

Related

401-Unauthrized when downloading file for Google Team drive

I am trying to access Team drive files using Drive Picker.
But I am getting this error
{
"code" : 401,
"errors" : [ {
"domain" : "global",
"location" : "Authorization",
"locationType" : "header",
"message" : "Invalid Credentials",
"reason" : "authError"
} ],
"message" : "Invalid Credentials"
}
So I tried to check in Google API Explorer and called the API by passing fileId and supportsTeamDrives = true. But in Google API explorer also, its giving me the same error.
What I am missing here?
Accessing Teamdrives uses a different method. List the files of the particular Teamdrive using the method Teamdrives: list, from there you will be able to get the Teamdrive id from the response just like below:
{
"kind": "drive#teamDrive",
"id": "XXXXXXIDXXXXXXX",
"name": "TheFileName"
}
You can then use the specific file id to get the metadata of a specific file from the method Teamdrives: get.

Mapping definition for [suggest] has unsupported parameters: [payloads : true]

I am using an example right from ElasticSearch documentation here using the Completion Suggestor but I am getting an error saying payloads: true is an unsupported parameter. Which obviously is supported unless the docs are wrong? I have the latest Elasticsearch app install (5.3.0).
Here is my cURL:
curl -X PUT localhost:9200/search/pages/_mapping -d '{
"pages" : {
"properties": {
"title": {
"type" : "string"
},
"suggest" : {
"type" : "completion",
"analyzer" : "simple",
"search_analyzer" : "simple",
"payloads" : true
}
}
}
}';
And the error:
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Mapping definition for [suggest] has unsupported parameters: [payloads : true]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Mapping definition for [suggest] has unsupported parameters: [payloads : true]"
},
"status" : 400
}
The payloadparameter has been removed in ElasticSearch 5.3.0 by the following commit: Remove payload option from completion suggester . Here is the comit message:
The payload option was introduced with the new completion
suggester implementation in v5, as a stop gap solution
to return additional metadata with suggestions.
Now we can return associated documents with suggestions
(#19536) through fetch phase using stored field (_source).
The additional fetch phase ensures that we only fetch
the _source for the global top-N suggestions instead of
fetching _source of top results for each shard.

Google drive api search query with partial match on property value

I am trying to use Google drive api through files().list().setQ(q).execute() where I have
q = "properties has { key='Code' and value contains 'abc' and visibility='PUBLIC' }"
Is there no option to use "contains" operator for value? I want to do partial matching on the value.
I get the following error (used in java).
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request { "code" : 400, "errors" : [ { "domain" : "global", "location" : "q", "locationType" : "parameter", "message" : "Invalid Value", "reason" : "invalid" } ], "message" : "Invalid Value" }
The exact same query works if I replace "contains" with "=" when there is an exact match.

How do i find a use the drive SDK to find a file using only drive.file scope

My scenario is that I want to look for a file, that if it exists, was created by my app.
If I request drive scope, I can use
/drive/v2/files?q=trashed%3Dfalse+and+title+%3D+'MyFile'+and+'root'+in+parents
and all is good.
But this requires access to all the users existing drive files, which is too demanding.
So I removed the drive scope and try the same command with only drive.file scope.
In return I get
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
Hacking around, if I remove the 'root' in parents, I get
{
"kind": "drive#fileList",
"etag": "\"Q5ElJByAJoL0etObruYVPRipH1k/vyGp6PvFo4RvsFtPoIWeCReyIC8\"",
"selfLink": "https://www.googleapis.com/drive/v2/files?q=trashed%3Dfalse+and+title+%3D+'MyFile'",
"items": []
}
which is better than a 500, but still not what I expected.
So how can I check if MyFile exists without requiring drive scope?
This is a known bug we're fixing soon.
GET https://www.googleapis.com/drive/v2/files/children?q=title+contains+'My title'
will also only list files from root that your application has right to access.

Google Drive: 500 Internal Error

I get this excepiton when requesting certain files. Any way to debug?
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 OK
{
"code" : 500,
"errors" : [ {
"domain" : "global",
"message" : "Internal Error",
"reason" : "internalError"
} ],
"message" : "Internal Error"
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:159)
at com.google.api.client.googleapis.json.GoogleJsonResponseException.execute(GoogleJsonResponseException.java:203)
at com.google.api.client.googleapis.services.GoogleClient.executeUnparsed(GoogleClient.java:237)
at com.google.api.client.http.json.JsonHttpRequest.executeUnparsed(JsonHttpRequest.java:207)
at com.google.api.services.drive.Drive$Files$Insert.executeUnparsed(Drive.java:307)
at com.google.api.services.drive.Drive$Files$Insert.execute(Drive.java:331)
This error seems to pop up when I try to create a folder with an empty name.
A more meaningful error msg would be great.
Using version 0.5.1-dev of grive on Ubuntu 16.04 I came across the error:
request failed due to temporary error: 500 (body: {
"error": {
"errors": [
{
"domain": "global",
"reason": "internalError",
"message": "Internal Error"
}
],
"code": 500,
"message": "Internal Error"
}
}
). retrying in 5 seconds
It would retry and repeat the error.
The solution was to create a dummy file within the directory.
I have opened an issue for this.