Import Statistics Integration (https://github.com/klausj1/homeassistant-statistics) Server Error 500 when uploading min, max, mean via ha rest api

Using c#, but also get the same error with PostMan when sending a http request to HA to upload previous history data to a HA entity.

url: http://192.168.xxx.xxx:8123/api/services/import_statistics/import_from_json
Method: POST
Headers: {Content-Type: application/json
Authorization: Bearer MyLongAuthString…

json string (body):
{“entities”:[{“id”:“sensor.br_scd30_sensor_humidity”,“unit”:“%”,“values”:[{“min”:41.11,“max”:41.11,“mean”:41.11,“datetime”:“26.02.2026 23:36”}]}]}

Also have tried:
{“entities”:[{“id”:“sensor.br_scd30_sensor_humidity”,“unit”:“%”,“values”:[{“min”:41.11,“max”:41.11,“mean”:41.11,“datetime”:“27.02.2026 00:12”}]}],“timezone_identifier”:“America/New_York”}

Can anyone tell me what the json string should look like?
Thank you.

You can not set the date and time for a when a value was registered.
It will always be when you make the post regardless of what value you might add.

There are integrations that can do it directly in the database through SQL commands, but it is not through HA’s interface.

Thank you for the quick response. I thought the idea behind the Import Statistics Integration (GitHub - klausj1/homeassistant-statistics: This HA integration allows to import and export long term statistics from/to a file like csv or tsv), was to import data from earlier time periods. The docs give an example of a json string for a sum import via HA rest api , but not for min, max, mean.
The docs show the endpoint as: http://yourserver/api/services/import_statistics/import_from_json

Ahh, yeah.
I did not see the text in the link.
The integration imports it directly into the database.
The sum feature might be a SQL function, but I do not know for sure.
The same functions might not exist for mean, min and max or they might just not be implemented.

Found my error. the datetime must only be at hourly intervals, with minutes of 00. Also, the time can not be more recent than 1 hour before the current hour. After that, it worked properly.