6

I recently requested a NOAA "token" to access their data. However, I keep receiving a "Token parameter is required" 404 error. Here is the URL I am using (note token is not the real one):

http://www.ncdc.noaa.gov/cdo-web/api/v2/locationcategories?Token=AbCdEfGhIjKl1234

I have been scouring google for about an hour now on just a simple example to see what I am doing wrong, but no luck. I'm hoping someone here can point out (and probably get a chuckle) what I am doing wrong.

6
  • 1
    Lowercase the string Token to token? Commented Nov 19, 2014 at 1:07
  • I tried that, and just did again to make sure, along with putting the token in single and double quotes. No luck.
    – ringraham
    Commented Nov 19, 2014 at 2:07
  • Have you tried using an HTTPS connection (to secure the token)?
    – Vince
    Commented Nov 19, 2014 at 2:39
  • Is there something in the real token other than plain characters and numbers?
    – BradHards
    Commented Nov 19, 2014 at 3:05
  • I tried the HTTPS connection idea which seemed plausible, but still no luck. The token consists only of upper and lower alpha chars. No numeric or special chars.
    – ringraham
    Commented Nov 21, 2014 at 0:19

4 Answers 4

10

I've figured out how to use their web services. It looks like you have to send the token as a header instead of directly in the URL. For example, you can download an add-on to your browser such as postman that allows you to send GET and POST requests to web servers. Then select the option to send a get request to the web server such as

https://www.ncdc.noaa.gov/cdo-web/api/v2/datasets

Then select the option to add a header. For the header, enter token for the header and whatever the value of your token is for the value. Select the Send button and you should get a result. Hopefully this helps you or somebody else in the future. Most programming languages such as python, ruby, Java, C#, etc. should have an option to send headers using a GET request.

2
  • Thanks for figuring this out. I never did get a response from them, but this looks like it should work. I'll give it a try in the next couple of days.
    – user25839
    Commented Jun 3, 2015 at 11:18
  • 1
    looks like it's all https now - they implemented a 301 redirect for http requests :)
    – pherris
    Commented Dec 19, 2016 at 20:19
4

According to the documentation, the token must go in the header, not the url:

An example using curl:

curl -H "token:<token>" url

An example using jQuery:

$.ajax({ url:<url>, data:{<data>}, headers:{ token:<token> } })

Example url:

http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datasetid=GHCND&locationid=ZIP:28801&startdate=2010-05-01&enddate=2010-05-01
2

In case anyone's trying to do this with PowerShell, here's an example:

$postparms =@{token="KkZJFCuahOZOxJFPaThisIsntAToken"}

Invoke-Restmethod -uri  http://www.ncdc.noaa.gov/cdo-web/api/v2/datasets -headers $postparms
0

In Python the following works:

import requests

my_headers = {'token' : 'xxxyyyzzz'}
response = requests.get('https://www.ncdc.noaa.gov/cdo-web/api/v2/datasets', headers=my_headers)
print(response.json())

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.