Getting message for few datatypes as "no default datasource found" for googlefit - google-fit

can anyone please let me know why I am getting this below message for some of the datatypes i am trying to execute.
https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
BODY:
{'aggregateBy': [{'dataTypeName': 'com.google.speed.summary',
}],'bucketBySession': {'minDurationMillis': 1},'startTimeMillis': 1600626600000,'endTimeMillis': 1600712999999}
Response:
{
"error": {
"status": "INVALID_ARGUMENT",
"message": "no default datasource found for: com.google.speed.summary",
"code": 400,
"errors": [
{
"reason": "invalidArgument",
"message": "no default datasource found for: com.google.speed.summary",
"domain": "global"
}
]
}
}

Related

Firestore queries: Invalid Payload Received

What am I trying to do?
Query the field named price in documents inside the collection named product_page and return the document where price==100
What did I do?
URL:https://firestore.googleapis.com/v1/projects//databases/(default)/documents/product_page/
METHOD: POST
Request Body:
{
"structuredQuery": {
"from": [
{
"collectionId": "product_page",
"allDescendants": true
}
],
"where": {
"fieldFilter": {
"field": {
"fieldPath": "price"
},
"op": "EQUAL",
"value": {
"stringValue": "100"
}
}
}
What error do I get?
code": 400,
"message": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document",
"description": "Invalid JSON payload received. Unknown name \"structuredQuery\" at 'document': Cannot find field."
}
You use the wrong endpoint (or method).
With the following URL and a POST method
https://firestore.googleapis.com/v1/projects/.../databases/(default)/documents/product_page
you actually call the createDocument method.
You need to use the runQuery method, which allows passing a structuredQuery object.

Method: projects.androidApps.create always return error

Note: I am posting this question regarding from this site suggestion
https://developers.google.com/explorer-help/support
parent=projects/887503652605
body
{
"name": "name",
"displayName": "d name",
"projectId": "pp",
"packageName": "ds.asdas.sdds",
"appId": "1:222475557139:android:b85702f52a4e128dcaaaaa"
}
Here what is appId and how to get it before adding app in firebase project
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
Try only:
{ "displayName": "d name","packageName": "ds.asdas.sdds" }
projectId is located in API: https://firebase.googleapis.com/v1beta1/projects/$PROJECT_ID/androidApps/
appId is given by firebase (unique)
name is given by firebase: projects/$PROJECT_ID/androidApps/$APP_ID

Use Apps Script URLFetchApp to access Google Datastore Data

I want to experiment with Google Datastore via Apps Script because I have a current solution based on Google sheets that runs into timeout issues inherent in constantly transacting with Drive files. I've created a test project in Google cloud with a service account and enabled library MZx5DzNPsYjVyZaR67xXJQai_d-phDA33
(cGoa) to handle the Oauth2 work. I followed the guide to start it up here and got all the pertinent confirmation that it works with my token (and that removing the token throws an 'authentication failed prompt').
Now I want to start with a basic query to display the one entity I already put in. I can use the API Explorer here and run this query body:
{
"query": {}
}
and get this result:
{
"batch": {
"entityResultType": "FULL",
"entityResults": [
{
"entity": {
"key": {
"partitionId": {
"projectId": "project-id-5200707333336492774"
},
"path": [
{
"kind": "Transaction",
"id": "5629499534213120"
}
]
},
"properties": {
"CommentIn": {
"stringValue": "My First Test Transaction"
},
"Status": {
"stringValue": "Closed"
},
"auditStatus": {
"stringValue": "Logged"
},
"User": {
"stringValue": "John Doe"
},
"Start": {
"timestampValue": "2017-08-17T18:07:04.681Z"
},
"CommentOut": {
"stringValue": "Done for today!"
},
"End": {
"timestampValue": "2017-08-17T20:07:38.058Z"
},
"Period": {
"stringValue": "08/16/2017-08/31/2017"
}
}
},
"cursor": "CkISPGogc35whh9qZWN0LWlkLTUyMDA3MDcwODA1MDY0OTI3NzRyGAsSC1RyYW5zYWN0aW9uGICAgICAgIAKDBgAIAA=",
"version": "1503004124243000"
}
],
"endCursor": "CkISPGogc35wcm9qZWN0LWlkLTUyMDAxxDcwODA1MDY0OTI3NzRyGAsSC1RyYW5zYWN0aW9uGICAgICAgIAKDBgAIAA=",
"moreResults": "NO_MORE_RESULTS"
}
}
I try to do the same thing with this code:
function doGet(e)
{
var goa = cGoa.GoaApp.createGoa('Oauth2-Service-Account',
PropertiesService.getScriptProperties()).execute(e);
if(goa.hasToken()) {var token = goa.getToken();}
var payload = {"query":{}}
;
var result = UrlFetchApp.fetch('https://datastore.googleapis.com/v1/projects/project-id-5200707333336492774:runQuery',
{
method: "POST",
headers: {authorization: "Bearer " + goa.getToken()},
muteHttpExceptions : true,
payload: payload
});
Logger.log(result.getBlob().getDataAsString());
}
and get this error in the logger:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"query\": Cannot bind query parameter. 'query' is a message type. Parameters can only be bound to primitive types.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"query\": Cannot bind query parameter. 'query' is a message type. Parameters can only be bound to primitive types."
}
]
}
]
}
}
If I try to use another word such as 'resource' or 'GqlQuery', I get this error:
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"GqlQuery\": Cannot bind query parameter. Field 'GqlQuery' could not be found in request message.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"description": "Invalid JSON payload received. Unknown name \"GqlQuery\": Cannot bind query parameter. Field 'GqlQuery' could not be found in request message."
}
]
}
]
}
}
I can't tell from the API Documentation what my syntax is supposed to be. Can anyone tell me how to compile a functional request body from Apps Script to Datastore?
You need to set the contentType of your payload as well as stringify your JSON payload as follows:
var result = UrlFetchApp.fetch(
'https://datastore.googleapis.com/v1/projects/project-id-5200707333336492774:runQuery',
{
'method':'post',
'contentType':'application/json',
'headers': {authorization: "Bearer " + goa.getToken()},
'payload':JSON.stringify(payload)
}
);

What is missing in this request to Google Maps Engine?

I want to use the batchInsert of Google map engine API. I am calling this with dojo/request.
Code to call the batch insert as below:
request("https://www.googleapis.com/mapsengine/v1/tables/1453899488279955151311853667273131550346/features/batchInsert",
{
headers : {
"Authorization": 'Bearer '+ token.access_token,
"Access-Control-Allow-Origin" : null,
"X-Requested-With": null,
"Content-Type": "application/json"
},
handleAs : 'json',
method : 'POST',
data :datastring
}
).then(function(data){
console.log("Got data :"+data);
}, function(err){
console.log("Got error :"+err.response.text);
}, function(evt){
console.log("Got Event :"+evt);
});
Request as below
{
"features":[
{"type":"Feature",
"geomerty":
{
"type":"Point",
"coordinates":[-34.678393740116476,150.765380859375]
},
"properties":
{
"gx_id":"2",
"FID":2,
"sapobjectid":"12345sdf",
"sapobjectname":"Test",
"Features":"Point"}
}
]
}
But I am getting the error as
Got error :{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "A value is required.",
"locationType": "other",
"location": "features[0].geometry"
}
],
"code": 400,
"message": "A value is required."
}
}
Please let me know what I am missing.
I think it's a syntax problem: "geomerty".
Try the request again using "geometry" instead.

Uploading File in Google Drive with setConvert(true);

i am trying to upload file in GoogleDrive with setConvert(true);
my code is as follows:
InputStreamContent mediaContent = new InputStreamContent(mimeType, new BufferedInputStream(new FileInputStream(filename)));
mediaContent.setLength(filename.length());
Insert insert = service.files().insert(body, mediaContent);
insert.setConvert(true);
insert.getMediaHttpUploader().setDirectUploadEnabled(false);
insert.getMediaHttpUploader().setProgressListener(new FileUploadProgressListener());
file = insert.execute();
its giving me below error
IOException: com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
"code": 500,
"errors": [
{
"domain": "global",
"message": "Internal Error",
"reason": "internalError"
}
],
"message": "Internal Error"
}