Skip to content

API does not return json when it asked to do #325

@FrederikWolter

Description

@FrederikWolter

Expected Behavior

I am trying to use the Get the 10000 latest measurements for a sensor method for a project
https://api.opensensemap.org/boxes/:senseBoxId/data/:sensorId?from-date=fromDate&to-date=toDate&download=true&format=json
to get the last 10000 measurements of my sensors.

Current Behavior

It seems like there is something wrong with the format attribute. When it is set to csv, it exports a .csv with time and value separated by a "," and a new row for each measurement.
Using format set to json, it exports a .json file but with the content formatted like csv; meaning there are no objects or arrays like you would expect from a json format.

Possible Solution

I am not into programming APIs but there probably something wrong with the method handling this kind of request.

Steps to Reproduce (for bugs)

For Example I used this request:
https://api.opensensemap.org/boxes/5cc2cfb9facf70001ac953f6/data/5cc2cfb9facf70001ac953fb?download=true&format=json&from-date=2020-03-01T00:00:00.000Z
An got as an answer a .json file containing this:

createdAt,value
2020-06-28T21:26:02.542Z,26.55
2020-06-28T21:23:28.338Z,26.56
2020-06-28T21:20:54.339Z,26.57
2020-06-28T21:18:20.391Z,26.58
2020-06-28T21:15:46.595Z,26.60
2020-06-28T21:13:12.392Z,26.61
2020-06-28T21:10:38.349Z,26.61
2020-06-28T21:08:04.326Z,26.62
2020-06-28T21:05:30.337Z,26.63
2020-06-28T21:02:56.388Z,26.65
2020-06-28T21:00:22.318Z,26.65
2020-06-28T20:57:48.663Z,26.65
2020-06-28T20:55:14.312Z,26.65
2020-06-28T20:52:40.509Z,26.65
...

It seems that this error just occurs when the download attribute is set to true too.

Context

Your Environment

  • Version used:
  • Environment name and version (e.g. Node v8.3.0):
  • Server type and version:
  • Operating System and version:
  • Link to your project:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions