Question About JSON Data Resource NOT Working

Hello,

I originally sent this to the AppGyver email address, then realized you prefer that we use the forum first. Sorry about that!

I am working hard to finalize the last big feature for an app I am building for a client, loading air quality data based on the city/state typed into an input field. I’ve already created a test page that loads data for a single city, but now I need to make this feature dynamic. I have a question about a data resource that does not seem to work for some reason.

  • So the original working data resource for the single city test page is a simple JSON file: Working Data Resource. This is an array of 14 objects, with 12 properties each, and it comprises a single air quality dataset for Phoenix AZ. It works in AppGyver. For example, I can bind the following formula to a Title component and pull the AQI number for the first object: data.AirNow850011[0][“AQI”] (app #131300 – AQI page)

  • This is a new failed data resource that I have truncated for easy testing: Broken Data Resource. This is an array of 3 objects, with 16 properties each, and is a shortened version of a much larger file. It does NOT work in AppGyver. I have followed the example of the working formula above, and tested it on the exact same component, but the field is blank when I test with the Preview App. Here is that formula: data.AQI_Data1[0][“AqiValue”] (app #178038 – Quiz Results page)

I have spent hours and hours attempting to sort this out. The JSON file validates, and I can build a schema with it. But no data will load when I preview the app.

Can you please take a look at my account to see if you can determine what could be the issue? I am hoping to be able to complete the NTAA app within the next week or so, and get it launched on the app stores.

My Apps

  1. Test App: #178038 – Quiz Results page . See screenshot here:


    (Data resource does NOT work in Preview App – either version)

  2. NTAA – Prototype App: #131300 – AQI page . See screenshot here:


    (Data resource works fine in both versions of the Preview App, as well as iPhone and Android builds).

As a follow-up, I launched the debugger and found that the “Broken Data Resource” above (AQI_Data1) does not seem to have any items:

Compare that to the Test App formula screenshot of the same data resource above.

Any ideas what could be causing this?

Thanks so much, I really appreciate your time!!!

Hi Anthony, hard to say what might be wrong here. I tested out the “broken data resource” and didn’t have any issues with it. :thinking:

I did the following:

  1. Created data resource from the JSON you linked
  2. Created data variable “AQI” with type “Collection of data records” to the page
  3. Tested with data.AQI[0][“AqiValue”]in a paragraph, got “26” (tip: you can also just write data.AQI[0].AqiValue)

Hi @Mari,

Thanks for testing the JSON file as a data resource. Unfortunately, I did the same as you, but the data resource is empty when I debug. Remember, I’ve created a number of data resources since beginning this app, so it is a relatively simple procedure in AppGyver. And I’ve added, deleted, added again and renamed this specific file and the related data resource info - including the data variable - all with no luck.

The real question is, why doesn’t the “AQIData.json” file work as a data resource from my account? Would it be possible for someone to look into that?

Thanks!

Hi,

I realize the AppGyver team is super busy with way cooler stuff, but if someone could just take a peak at my account - specifically regarding the issue surrounding why this JSON file does not work from my account, you would be a life saver!

I’ve even created a new app called “API Tests”. It only has one page “Test1”. It has a Title component, and a Paragraph component. I’m using this formula on the Paragraph component: data.apitest1[0].AqiValue

The data resource is the JSON file mentioned above.

The app ID is 188047.

Thanks!

Hi Anthony, sorry for not being able to get back sooner, I completely understand your frustration with this issue! I took a look at the test app and the resource is working correctly for me both in the preview app and in the web preview:

It’s difficult to say why the resource would be working elsewhere but not on your account/device specifically, but I can try to look into it further.

Did you make a build version of the app using this resource yet? How did it behave?

Hi Mari,

Thanks for taking the time to test, and show screenshots, I really appreciate it!

So, I’ve been working on this app for a couple months, and because I have always been able to test all of the other features and data resources first on Android, which is my primary device, it never occurred to me to test this specific issue on the iPhone. The data point “26” shows on both iPhone 6 and iPhone X using the Preview App, so it works. It does not show with the Preview App on either of my Android devices, which have 8 and 10 installed. The Android 8 device is a 2017 device, and the Android 10 device is new, only a couple months old.

I also never thought to test a build, which I now have on Android 10. No luck! So for some reason, this particular JSON file does not work on Android, whether with the Preview App, or an on-device build. That does not make sense. It’s just JSON, and I’ve run it through a number of online validation services.

Do you have someone on your team who can test this issue on Android, just to make sure I’m not stuck in some alternate universe?.. lol

Hi, that does sound super weird, but good that you were able to pinpoint the issue to Android! I’ll ask around if someone has an Android device to test, I unfortunately don’t have one at hand.

Just out of curiosity, how about the original app that also had a JSON resource configured this way, does that still work on Android too?

Yeah, that’s the really weird part. This “broken” JSON data resource is the new one - a small sampling of a much larger data file from the EPA’s AirNow service, which I need for the final feature. All of the other data resources, which are either JSON files or WordPress API, still work perfectly. I even tested a random non air quality JSON file, and it work perfectly.

Even weirder, Data References in the debugger show zero items:

But the Schema shows everything is there:

Hm, apart from the slightly different formatting/indentation there’s really nothing that stands out in the file. Does the debug console have any errors when you run the app on Android? Have you been working with the same JSON file or tried to re-create and re-upload it?

Maybe most importantly, have you tried connecting the actual AirNow resource yet to see if that would work? Best case scenario, that works and you can forget about the problems with the test file. :smile:

Here is the debug console showing a page with the new and old data resources:

And here is the Data References for those:

The top and bottom two are all different versions and tests of the new JSON file, all of them empty on Android. The two in the middle are the older and functioning JSON data resources.

I forgot to add that the new JSON file, the smaller test version, is only being used because the original did not work. I wanted to slim it down to see if I could pinpoint the problem. Here is the original.

AirNow does not currently provide a CORS enabled API, but I have asked repeatedly for it for mobile app development. I heard back recently that they are in talks to either enable CORS, or provide an alternate API for app developers.

Ah, I see. I wonder if the 403 forbidden error could be related or is it also present on iPhone/web preview?

The 403 error is also showing when debugging the iPhone, before choosing an app.

Okay, so it’s unrelated. I’ll see if I can get my hands on an Android device tomorrow to try it out. :slight_smile:

1 Like

Hi @Mari,

Any luck with finding someone who can test on an Android?

Hi, just tested on an Android phone and I can’t see the data in the preview app either.

Hi @Mari,

Thanks for your tests on Android. As a staff member, I wonder if you might be able to shed some light as to why Composer Pro is showing a valid response in the formula binding editor for data.apitest1[0].AqiValue, if it only works on iPhone?

I also wonder if there might be some kind of internal error reporting (from an engineer’s perspective) that can be seen when an Android device loads a page that has the above formula, but fails to return the same data as an iPhone? If I knew what the issue was, I would at least have an opportunity to try and resolve it.

Thanks again!

Hi Anthony, sorry I just had time for a brief confirmation on Friday. I’ve replicated the use case so that our engineering team can take a look at what’s happening here. The formula binding editor shows a valid response since the setup should be valid, there just seems to be unexpected behavior down the line and the values are not getting populated when the app is run. Please keep the resources up until we’re able get to the bottom of this. :slight_smile:

I’m unfortunately not that familiar with debugging tools, but in this thread Sasu suggested adb for getting error logs from Android apps that have already been built.

Thanks Mari, looking forward to your engineering teams findings! :slight_smile:

Hi @Anthony_Williamson! appears that your JSON file has a byte order mark before the first [ character. Other clients know how to ignore this but apparently Android has issues reading the file because of this. We’ll aim to fix that in the future, but for now you should be able to get the file to work by simply opening the JSON file in a hex editor and removing the character from the beginning.

Furthermore, if you can configure the Content-Type response header from your backend from application/json to application/json; charset=utf-8, that will also help the client read the files in the correct encoding.

image

1 Like