WebViewer works, WEB doesn't!?

I am trying to build an app that retrieves river gauge levels using the USGS waterservices RESTful API. Their website has a tool to generate the specific URL for the data you want (eg, which river, which gauge, etc). I would like to use the WEB component to retrieve this data so that I can more easily parse the information I want, however I always get an "Error: 1101: Unable to get a response...". The same URL works fine in the WebViewer component. Perhaps the URL does not link to a true API service, although the documentation says:

"The URL must always be in this format:

http://waterservices.usgs.gov/nwis/iv/?

where are one or more HTTP GET parameter names and values based on the information below."

Barring success at using the WEB component to retrieve the desired information, any advice on how to easily extract the data (river level in this case) from all the other information provided by the WebViewer component would be appreciated.

The test app I'm using is simple, but here are the block:

image

Thanks much!

The end of the URL you used is not visible in your screen shot.

If you post an exported .aia we can investigate further.

My bad. The complete URL is:

https://waterservices.usgs.gov/nwis/iv/?format=rdb,1.0&indent=on&sites=06935965&parameterCd=00065&siteType=ST&siteStatus=active

Here is the aia file: Web_vs_WebViewer.aia (2.1 KB)

Thank you.

The problem seems to be with the Android device level.
I had similar trouble using the stock AI2 emulator,
but success with a GenyMotion recent Pixel 8 emulator.


See https://help.waterdata.usgs.gov/known-problems/mobile-water-data
for confirmation about device types.

The data source is interesting, but I find the rdb tab-delimited format painful,
compared to their JSON format, which can be readily decoded using the AI2
web component’s JSON text decode block and the new Dictionary data types.

FYI, the tab character in AI2 text blocks is \t, and newline is \n.
To decode rdb output, split the incoming text at \n.
remove from the resulting list all items starting with '# ',
split the first item at \t to get header names,
remove the first 2 rows to get to the data,
and split each data line at \t to get cells of that table row.

Web_vs_WebViewerAbg.aia (3.1 KB)

1 Like

Thanks much for your time and effort to help solve this problem. Looks like my Android version (4.4.2) has an issue with the USGS database I’m trying to use. Thought maybe I was missing something with regards to the components – thanks again for putting my mind at ease!