0

I understand C# and VB, but am a bit new to web development. I am trying to write a VB web app to pull data using NOAA's new (V2) API. Their site says to first request a token (done). Then to add it to the header and use a base URL (http://www.ncdc.noaa.gov/cdo-web/api/v2/) and append the appropriate endpoint after v2/...

It then gives me:

Header
token

Usage
curl -H "token:<token>" url
OR
$.ajax({ url:<url>, data:{<data>}, headers:{ token:<token> } })
Where <token> is the token obtained from the token request page. 

My question is:

  1. How do they want me to add the token to the header? (I've tried a meta tag, but not sure if I added it properly) and
  2. How do I use that jquery ($.ajax) to pull the data I want?
Fish Below the Ice
  • 1,273
  • 13
  • 23
toadfromgrove
  • 143
  • 2
  • 14

1 Answers1

0

The header they want you to add is not a header in the HTML (i.e. not <head><meta token=token>). The header they want is an HTTP header in the request (that's what the -H option to curl does).

For JQuery, you pass a header in the options hash:

$.ajax({ url: 'foo/bar', headers: { 'token': 'token value' } });

Which is what they are showing you under the curl command in the text you pasted: $.ajax({ url:<url>, data:{<data>}, headers:{ token:<token> } })

See more about adding headers to $.ajax here

Jim Deville
  • 10,632
  • 1
  • 37
  • 47
  • Thank you for your response! Ok so using JQuery (don't want to try using cURL) I have all three pieces to that $.ajax command, how do I implement $.ajax to get data I need? Do I put it somewhere in my aspx page or in my code behind? Sorry, like I said new to web developing in particular – toadfromgrove Aug 04 '15 at 14:51