I am trying to add a specific datasource and the scopes are
https://www.googleapis.com/auth/fitness.activity.read
https://www.googleapis.com/auth/fitness.activity.write
But when I try to do so. It returns me an error of
{
"reason": "invalidArgument",
"message": "Data type does not match well-known data type with the same name",
"domain": "global"
}
I send POST request to this URL
https://www.googleapis.com/fitness/v1/users/me/dataSources
Here is my request body
{
"dataStreamName": "MyDataSource",
"type": "derived",
"application": {
"detailsUrl": "http://example.com",
"name": "Foo Example App",
"version": "1"
},
"dataType": {
"field": [
{
"name": "activty_type",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"device": {
"manufacturer": "Example Manufacturer",
"model": "ExampleTablet",
"type": "tablet",
"uid": "1000001",
"version": "1.0"
}
}
I am using PHP/Laravel as a language and I use CURL as an http request library. Can someone tell me what did I do wrong? Some of the scopes are successfully added but there are others that cannot be added.
Google docs reference: https://developers.google.com/fit/datatypes/activity?authuser=3
According to the documentation, activity_type (which you have a typo in) isn't the correct string. com.google.activity.segment
requires activity
field.
See documentation.
So this would, as it returns expected resource and HTTP 200 in the Google Fit API Testing Console, work:
{
"dataStreamName": "MyDataSource",
"type": "derived",
"application": {
"detailsUrl": "http://example.com",
"name": "Foo Example App",
"version": "1"
},
"dataType": {
"field": [
{
"name": "activity",
"format": "integer"
}
],
"name": "com.google.activity.segment"
},
"device": {
"manufacturer": "Example Manufacturer",
"model": "ExampleTablet",
"type": "tablet",
"uid": "1000001",
"version": "1.0"
}
}