dten
dten

Reputation: 2374

Google Fit REST API "Unable to fetch DataSource for Dataset: xyz"

I'm testing out a few things in the OAuth 2.0 Playground and trying to get data in and out of Google Fit using their REST API

I have done this previously with success, I just didn't write down what I did.. now I've come back to make it a proper thing and can't get it working again.

I have access to Google Fit datasources via the dashboard. I can get a list of the dataSources that exist from:

https://www.googleapis.com/fitness/v1/users/me/dataSources

And that is successful. I have also created my own stream which has a single floating point weight value on it called

raw:com.google.weight:b6ac18c0:dten.sync

It already has data in it, I put it there last time I used it. I can select all that data by requesting a GET on the following

https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/0-1432193482000000000

It returns me all the data points I entered last time as JSON

I then try to PATCH the data adding my own data to the folliwng URL

https://www.googleapis.com/fitness/v1/users/me/dataSources/raw:com.google.weight:b6ac18c0:dten.sync/datasets/1432193482000000000-1432193482000000000

With this as a the request body

{
  "minStartTimeNs": "1421912895000000000",
  "maxEndTimeNs": "1432193482000000000",
  "dataSourceId": "raw:com.google.weight:b6ac18c0:dten.sync",
  "point": [
    {
      "startTimeNanos": "1421912895000000000",
      "modifiedTimeMillis": "1421912895000",
      "endTimeNanos": "1421912895000000000",
      "value": [
        {
          "fPVal": 89.1
        }
      ],
      "dataTypeName": "com.google.weight"
    }
  ]
}

But I get back

{
  "error": {
    "code": 400, 
    "message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync", 
    "errors": [
      {
        "domain": "global", 
        "message": "Unable to fetch DataSource for Dataset: raw:com.google.weight:b6ac18c0:dten.sync", 
        "reason": "invalidArgument"
      }
    ]
  }
}

I can't find any one referencing a similar anywhere soo I'm here

Also note if I miss spell my source it tells me off because they don't match the URL, if i include an empty list of data points I get the same error. I'm quite lost so I'm throwing it out there to see if anyone knows what that means

Thanks in advance

edit: i tried changing the hex code for my project's integer code and got an error about untrusted source. so i tried making a new test data source which works as expected. Slightly annoyed but guess I'll just start over..

Upvotes: 0

Views: 2122

Answers (1)

dten
dten

Reputation: 2374

OK I was stupid and didn't set up my own credentials in the OAuth settings in top right of the dashboard as it said to here. I forgot that bit -_- now I can access my own stream again and it shows my integer project id in the stream id not the hex one

https://developers.google.com/fit/rest/v1/get-started

Now I get invalid argument, but.. whatever >_<

edit 2:

invalid argument was because I have fPVal instead of fpVal and modifiedTimeMillis mills is not supposed to be submitted, obviously

Upvotes: 1

Related Questions