NOAA Weather REST API throws error when requested with curl

I am trying to write a python program using NOAA Climate Data Online REST Web Services ( http://www.ncdc.noaa.gov/cdo-web/webservices/v2#data ). But I am running into errors in my request for answers. When trying to request with curl from the command line, I enter:

curl -H "token:<MYTOKEN>" http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&locationid=ZIP:22405&startdate=1999-10-05&enddate=1999-10-25

      

It returns this response:

[1] 24322
[2] 24323
[3] 24324
phil@philUbu:~$ <?xml version="1.0" encoding="UTF-8" standalone="yes"?><response><statusCode>400</statusCode><userMessage>There was an error with the request.</userMessage><developerMessage>Required parameter 'startdate' is missing.</developerMessage></response>
[1]   Done                    curl -H "token:..." http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND
[2]-  Done                    locationid=ZIP:22405
[3]+  Done                    startdate=1999-10-05

      

For some reason, it thinks I am missing a start date, but I included it and it matches the format as per the documentation. Does anyone have any ideas on what the problem might be?

+3


source to share


1 answer


The ampersands in the url are probably being handled by your shell. Place single quotes around it:



 curl -H "token:<MYTOKEN>" 'http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&locationid=ZIP:22405&startdate=1999-10-05&enddate=1999-10-25'

      

+1


source







All Articles