A problem that I can't find a solution with Apis

Hi, I'm Chaira, I'm 13 years old. I'm learning by self-taught how to use MIT App Inventor, and I'm having a problem with the web component. My App idea was looking for information on an Api and then showing it on a list component. but it doesn't show the information. In the Code I look for the Geocode of the user to use it in the URL and next It put all together. I will upload the image in this mail so you can see it. I look in a lot of websites and ask IA what happens and I don't find the problem.
When I try to use the Api in my browser (with the same data from the App) It works, but in the App It doesn't show the information!!!
Can you help me, please?
The first column of the code looks for the latitude and longitude of the user, It also rounds the Geocode to show only 2 decimals of the latitude and longitude because it's what Apis need. Next is the URL creating part of the code, I forgot to tell you about a message that usually appears that says : The operation Elements cannot accept the arguments: , ["application"]. I think that this error is related to the creation of this or the second URL for the Api (I'm using 2 Apis) What could It be?

In the second column of code it tries to show the information of the api, it also creates a new variable that was use to get information of the first Api (I'm coding this part but for that it's necessary to make the Api work).

The last part doesn't affect the running of the app, because are only variables.

Thank you so much for your help.


Other information that will be helpful:
1 Api documentation:

2 Api documentation: Weather Company Data - Enhanced Current Conditions - Current Conditions - PWS Observations - Current Conditions - v2 - Google Docs

Hmm. So if the JSON you show in the first image is what you're expecting to get back, then it doesn't make a ton of sense to simply decode that and feed it into the Elements property since it expects a list of strings. If you temporarily disable that last block in the event handler and instead dump the NearPWSApiView contents into a label, does it look like the JSON you expect? If not, we should debug that first.

1 Like

in your wepnearpwsapi got text box, you should check for responsecode of 200 (usually 200 means successful call), then get the responsecontent and save it in a label so you can see if it's in the right format.thisis a sample
image

the major key is 'location' and within a location is a field called 'stationName' which is a list of multiple values , there is also a field called 'stationid' which is a list of the corresponding names, etc. once you see the structure you can parse the json to obtain the key you want.

set listview elements block requires a list so you will need to create a list from the contents of the returned json string according to your needs.
good luck!

1 Like

thank you a lot, I'm going to try doing it in that way!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.