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:
$.ajax
) to pull the data I want?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