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.

  • 1
    Lowercase the string Token to token? – Jason Scheirer Nov 19 '14 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 Nov 19 '14 at 2:07
  • Have you tried using an HTTPS connection (to secure the token)? – Vince Nov 19 '14 at 2:39
  • Is there something in the real token other than plain characters and numbers? – BradHards Nov 19 '14 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 Nov 21 '14 at 0:19
9

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.

  • 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 Jun 3 '15 at 11:18
  • 1
    looks like it's all https now - they implemented a 301 redirect for http requests :) – pherris Dec 19 '16 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
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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