Page 1 of 1

Data via API adds to existing data for same date

Posted: Sat 10. Apr 2021, 11:00
by mstuebner
Hi there,

I accidentally found that under certain circumstances data can be added, although for that date already exists.

When I insert mental data that already exists I get:

Code: Select all

Response 'Datapoint already exists' for mental status at 2021-04-09T06:00:00Z
Response 'Datapoint already exists' for mental status at 2021-04-10T06:00:00Z
When I added heartraterest data via api before, I get the same response:
Response 'Datapoint already exists' for heartrate rest at 2021-04-09T06:00:00Z
Response 'Datapoint already exists' for heartrate rest at 2021-04-10T06:00:00Z
That is different when data was already added via sync. When I then run the same code for the same date, I get the following response:
Response 'Datapoint successfully created' for heartrate rest at 2021-04-09T06:00:00Z
Response 'Datapoint successfully created' for heartrate rest at 2021-04-10T06:00:00Z
Only visible difference is, that the heartrate doesn't have a time when synced automatically, of course has one when I add data via api.
The existing data (from sync) is not overridden, the new data is just added, messing up the history.

So to me it seams that the check for existing data requires a time to be existing, but for some reasons the heartraterest that is synced from Garmin doesn't get a time assigned.

br Matthias

Re: Data via API adds to existing data for same date

Posted: Sat 10. Apr 2021, 11:26
by mipapo
Mental state allows only one entry per day.
For resting heart rate we allow multiple entries per day, due to historical reasons, but we don't recommend it to add multiple per days as it doesn't make sense. And the check will always ignore the time.

So just disable the sync for Garmin resting heart rate, if you want to provide them via API.

Re: Data via API adds to existing data for same date

Posted: Sat 10. Apr 2021, 13:51
by mstuebner
mipapo wrote: Sat 10. Apr 2021, 11:26 Mental state allows only one entry per day.
For resting heart rate we allow multiple entries per day, due to historical reasons, but we don't recommend it to add multiple per days as it doesn't make sense. And the check will always ignore the time.

So just disable the sync for Garmin resting heart rate, if you want to provide them via API.
I want to fill heartraterest only if there is no data from Garmin (why ever). Therefore I expected to get a "already" exist in cases where a heartrate is set already.

I didn't see and rest endpoint that allows me to test whether there is any heartraterest already set? Can I check that in a different way?

br Matthias

Re: Data via API adds to existing data for same date

Posted: Sat 10. Apr 2021, 15:41
by mipapo
No sorry, there is no option for it