Home > Net >  OpenWeatherMap posting measurements returns "204 No Content"
OpenWeatherMap posting measurements returns "204 No Content"

Time:09-17

I am trying to use the new OpenWeatherMap Stations API to post measurements from my local weatherstation to the OWM DB. I will be using a Raspberry Pi server for this, but for now I want to test out the api. I am using Postman to do some requests. I have already created a valid station with my api key.
A few weeks back I posted one measurement to it, and I can see that measurement was saved when I do a GET request on this station id. I saved the request in Postman and tried the same request (adjusted the date) but the api returns "204 No Content".
This is the curl request I am sending (used the example from the api docs):

curl --location --request POST 'http://api.openweathermap.org/data/3.0/measurements?appid=<my_api_key>' \
--header 'Content-Type: application/json' \
--data-raw '[
  {
    "station_id": "<my_station_id>",
    "dt": 1631613233,
    "temperature": 20.0,
    "wind_speed": 1.2,
    "wind_gust": 3.4,
    "pressure": 1021,
    "humidity": 87,
    "rain_1h": 2,
    "clouds": [
      {
          "condition": "NSC"
      }
    ]
  }
]'

And this is the answer I am getting from the API (the body is empty):

{
  'Server': 'openresty',
  'Date': 'Tue, 14 Sep 2021 09:53:54 GMT',
  'Connection': 'keep-alive',
  'Access-Control-Allow-Origin': '*',
  'Access-Control-Allow-Credentials': 'true',
  'Access-Control-Allow-Methods': 'GET, POST'
}

Has somebody encountered this before, or am I missing something obvious? Thanks in advance.

EDIT: As I was looking today (on the next day after I posted this), my measurements where saved. Apperently it takes a few minutes (or hours?) for the api to update. If anyone knows why that might be, please let me know.

CodePudding user response:

Their docs says that

In case of successful measurements dispatch method returns an HTTP code 204.

It means your request was successful, now you can GET info.

  • Related