Unable to access National Weather Service API

I'm trying to access alert information from api.weather.gov, and it works fine in google. However, when I try accessing the URL in app inventor, it gives me the following error:

Does app inventor block this API, or does the API not work with app inventor?
The exact URL I am trying to access is https://api.weather.gov/alerts/active.
Here is my code:

Any help would be greatly appreciated.

This isn't a block enforced by App Inventor. It just tries to do whatever you instruct it to do. Given that you get a result from the weather service, it shows that they are the one returning an error. One issue I'll note in your blocks is that you check whether responseCode is 403 or not. If an HTTP request is successful, the responseCode from the server will be 200. HTTP 403 indicates that the request is forbidden. You realistically want to check whether the responseCode is 200 and proceed accordingly.

So there's no way to get this to work?

I think we need to understand why you're receiving an error response. Totally independently, we have a student working on this particular API and we have gotten things working there. My immediate guess is that you need to be sending an Authorization header by setting up the RequestHeaders property properly. When you say you are testing this in your browser, are you using a Swagger-style interface or are you just opening the URL directly?

I'm just opening the URL directly.

Please post a link to the documentation of the API... probably there is something missing in your blocks...


So I poked around at this and I think the issue is that the server wants a User-Agent header for some purpose. Most clients include one by default by App Inventor does not since we don't know what the final name of your app will be. For example:

After fixing that I did encounter a more serious bug that is causing an exception to be thrown when parsing the GeoJSON into features. I think it should be fixable as part of the next companion update.

The active alerts URL works for me in a browser:
Alert.txt (4.8 MB)

But neither http nor https requests will be tolerated from the AI2 web component.
Both get a 403 Access Denied.

browse_JSON_weather_alerts_active.aia (20.3 KB)

This site clearly hates being scraped.

Check their web site to see if you need to add an API license key.


yes exactly... therefore reading the documentation helps...
thank you @SteveJG


A User Agent is required to identify your application. This string can be anything, and the more unique to your application the less likely it will be affected by a security event. If you include contact information (website or email), we can contact you if your string is associated to a security event. This will be replaced with an API key in the future.

User-Agent: (myweatherapp.com, contact@myweatherapp.com)


Thank you all for these helpful responses! I will attempt them when I am able to!

I got a sample setup to work:
browse_JSON_weather_alerts_active.aia (20.8 KB)

Press the Web button to request from the Web. It might take a couple of seconds for a response. When the display changes, press the JSON button to parse it as JSON and launch a tree climb into it.

1 Like