Reputation: 389
I'm new to Android Studio and I'm currently trying to create an app that uses the NOAA web service. I'm terribly confused on how to retrieve the data from this API. I have a token, but I'm not sure how to get started. I don't want to use a SOAP client, I need the response to be in JSON. This weather functionality is part of a much larger app that's written in Java, developed in Android Studio, and expects a response in JSON that is then stored in a database, so I need to use the API v2, and a lot of examples use the API Legacy.
The documentation (http://www.ncdc.noaa.gov/cdo-web/webservices/v2) provides a base url and endpoints, but then it starts talking about headers and using "curl -H "token:" url or $.ajax({ url:, data:{} headers:{ token: } })". From what I can tell, neither one of these is used for Java development and the curl -H is for Linux or some jquery stuff?
App needs to use a lat/lon position to get hourly weather data. I get that I need to use HttpURLConnection and what not, I'm getting stuck at what type of object I need to create for a header and base url with the parameters. Can I even use java and android studio to do this?
Upvotes: 1
Views: 539
Reputation: 3890
curl is just a unix command line tool to do http-requests. You can do http requests in almost any language you like, as the HTTP is only a protocol. You need to know the basics of HTTP-protocol for almost all internet related programming, regardless what language you use.
The nice thing of curl that you experiment with it on the command line, without writing real programs. so you can change the parameters of the request, and see what response you get. Than all you need to do is to do the requests (including the http-headers and especially the authentication) with java.
And then of course you need to analyse the response, which is in json format, so you need a json parser (or for simple responses it may be possible to fake it, for example with regular expressions. But sooner or later you need to use a real json parser)
Upvotes: 1