Help! All of my FEMA API projects stopped working since March 2

I have been working with the PRO version of Thunkable X for a few months now as part of a Social Good App unit for my 10th graders. I have been working with my students to figure out different APIs and I have developed a number of Starter Projects that show the students how to set up their coding for this. For some reason, all of my FEMA API projects stopped working since March 2. Is there something going on with Thunkable? They were working just fine a couple of days ago. Could there be an issue with FEMA?

I can set the API URL just fine. I send the API url to a web page and I get the data for the url just fine. That still works, but when I try to GET anything, the screen flashes, goes blank, and says I need to restart my project.

Here is one of the projects: Thunkable

Here’s an image of the code for this project:

Again, all my different FEMA projects were working fine a couple days ago.

Any help would be great. My students are finishing their apps this week.

1 Like

You are not testing/checking the green error block. If there is an error in the API you wouldn’t know without checking the error block first before attempting to use the response block.

Refer to the following tutorial for better understanding of API error handling.

I love to hear about this sort of thing. I teach Thunkable to my students, too, in an elective for 7th and 8th graders. The educator category is so quiet around here… but I know there are teachers lurking. :slight_smile:

Thanks, @muneer, I do hope that my tutorial is helpful.

That URL is a little complicated to reconstruct but I think I got it: $filter=declarationDate gt '2021-01-01T04:00:00.000z' and state eq 'CA' and incidentType eq 'Fire'&$inlinecount=allpages

(I chose the year 2001, the state CA, and ‘Fire’ for the incident type).

I always test the URL in a browser before I worry about what’s happening in Thunkable.

I get this JSON response from that url… so to answer your question, it seems like FEMA is still working. :wink:

{"metadata":{"skip":0,"top":1000,"count":0,"filter":"declarationDate gt '2021-01-01T04:00:00.000z' and state eq 'CA' and incidentType eq 'Fire'","format":"json","metadata":true,"orderby":{},"select":null,"entityname":"DisasterDeclarationsSummaries","version":"v2","url":"/api/open/v2/DisasterDeclarationsSummaries?$filter=declarationDate%20gt%20%272021-01-01T04:00:00.000z%27%20and%20state%20eq%20%27CA%27%20and%20incidentType%20eq%20%27Fire%27&$inlinecount=allpages","rundate":"2021-03-04T05:46:18.301Z","DeprecationInformation":{"depDate":null,"deprecatedComment":"","depApiMessage":"","depNewURL":"","depWebMessage":""}},"DisasterDeclarationsSummaries": []}

When formatted, that looks like this:

You’re trying to get objectmetadatacount. In my example, that value equals 0. You’re also trying to get objectDisasterDeclarationsSummaries[first list item]incidentBeginDate. In my example, that value is an empty array/list. So if I try to assign it to a label’s Text in Thunkable, I’m probably going to generate an error/crash.

This is why error checking is so important with APIs. You need to be prepared (FEMA term!) for missing or blank data such as that. And you should always check the green error block’s value. I use an If/else block in my projects to do that, which you can see starting at the 17:09 mark in the video @muneer linked to.

1 Like

Thunkable support told me there is a bug in the GET API blocks. They just fixed it. So hard refresh or purge cache and you should be good. All of my projects are working now.

Thank you so much for all your help. I learned a lot about how to work with APIs which will help me in the future.