Travel App Api is correct but App hangs

https://x.thunkable.com/copy/487ef67fbfc6fcac01f745bff56a36a1

Travel Api i m using is verified from Rapid Api(Hotels)…but when i click on search …App just closes.
kindly help

It’s helpful if you can provide the full JSON response you’re getting when you click the Search button. To do that, assign the green response block to a Text Input. Either remove all other blocks after that or add a long wait (say, 5 seconds) so that you have time to copy the response before the app crashes.

Paste the full JSON here as text and we can probably help you solve this.

It’s also helpful if you post a link to the documentation for the API you’re using.

I do see on Rapid API that the url you’re using is deprecated and should be replaced with “https://hotels4.p.rapidapi.com/locations/v3/search

Ok i will do that…thanx

I noticed several problems with the blocks you’re using:

  1. You assigned an empty string (“”) to app variable numberofHotels when you initialized it but then you set it to an empty list. It can’t be a string and a list. You have to choose one type of variable. So I’d remove the empty string from the initialize block. You can initialize it to an empty list but you don’t have to.

  2. You’re using a parameter called “name” but in the documentation, that parameter is called “q”.

  3. I noticed that the locale for the U.S. is “en-US”. Upper/lower case matters so if it’s supposed to be “en-GB”, you need to change that. Edit: “en-gb” works just fine.

  4. The response I get from the endpoint test on the Rapid API site has “q” as the property name so if you try to get the property called “name”, it’s going to fail and crash your app.

  1. I don’t see a list in the response, except in the “sr” property, which would be indicated by square brackets (). Where did you find that? Again, if you can post the full JSON response here, it will be very helpful.

Ok cool…i will change it

Here’s a successful way to get at least one property value (“fullName”) from the API:


this the response i got

{"q":"berlin","rid":"097d0acd78d84737aafd0c013e88dcd6","rc":"OK","sr":[{"@type":"gaiaRegionResult","index":"0","gaiaId":"536","type":"CITY","regionNames":{"fullName":"Berlin, Germany","shortName":"Berlin","displayName":"Berlin, Germany","primaryDisplayName":"Berlin","secondaryDisplayName":"Germany","lastSearchName":"Berlin"},"essId":{"sourceName":"GAI","sourceId":"536"},"coordinates":{"lat":"52.51384","long":"13.35008"},"hierarchyInfo":{"country":{"name":"Germany","isoCode2":"DE","isoCode3":"DEU"}}},{"@type":"gaiaRegionResult","index":"1","gaiaId":"183784","type":"CITY","regionNames":{"fullName":"Berlin, Ohio, United States of America","shortName":"Berlin","displayName":"Berlin, Ohio, United States","primaryDisplayName":"Berlin","secondaryDisplayName":"Ohio, United States","lastSearchName":"Berlin"},"essId":{"sourceName":"GAI","sourceId":"183784"},"coordinates":{"lat":"40.561173","long":"-81.794304"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaRegionResult","index":"2","gaiaId":"79155","type":"CITY","regionNames":{"fullName":"Berlin, Maryland, United States of America","shortName":"Berlin","displayName":"Berlin, Maryland, United States","primaryDisplayName":"Berlin","secondaryDisplayName":"Maryland, United States","lastSearchName":"Berlin"},"essId":{"sourceName":"GAI","sourceId":"79155"},"coordinates":{"lat":"38.322709","long":"-75.217933"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaRegionResult","index":"3","gaiaId":"6382","type":"CITY","regionNames":{"fullName":"Berlin, New Hampshire, United States of America","shortName":"Berlin","displayName":"Berlin, New Hampshire, United States","primaryDisplayName":"Berlin","secondaryDisplayName":"New Hampshire, United States","lastSearchName":"Berlin"},"essId":{"sourceName":"GAI","sourceId":"6382"},"coordinates":{"lat":"44.468669","long":"-71.185076"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaRegionResult","index":"4","gaiaId":"601763","type":"CITY","regionNames":{"fullName":"Burlington, Vermont, United States of America","shortName":"Burlington","displayName":"Burlington, Vermont, United States","primaryDisplayName":"Burlington","secondaryDisplayName":"Vermont, United States","lastSearchName":"Burlington"},"essId":{"sourceName":"GAI","sourceId":"601763"},"coordinates":{"lat":"44.476578","long":"-73.21254"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaRegionResult","index":"5","gaiaId":"553248635056399195","type":"POI","regionNames":{"fullName":"Lou Berliner Sports Park, Columbus, Ohio, United States of America","shortName":"Lou Berliner Sports Park","displayName":"Lou Berliner Sports Park, Columbus, Ohio, United States","primaryDisplayName":"Lou Berliner Sports Park","secondaryDisplayName":"Columbus, Ohio, United States","lastSearchName":"Lou Berliner Sports Park"},"essId":{"sourceName":"GAI","sourceId":"553248635056399195"},"coordinates":{"lat":"39.93197987610981","long":"-83.00661943987757"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaRegionResult","index":"6","gaiaId":"7146","type":"CITY","regionNames":{"fullName":"Burlingame, California, United States of America","shortName":"Burlingame","displayName":"Burlingame, California, United States","primaryDisplayName":"Burlingame","secondaryDisplayName":"California, United States","lastSearchName":"Burlingame"},"essId":{"sourceName":"GAI","sourceId":"7146"},"coordinates":{"lat":"37.577869","long":"-122.348091"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}},{"@type":"gaiaHotelResult","index":"7","hotelId":"57232524","type":"HOTEL","regionNames":{"fullName":"Steigenberger Airport Hotel Berlin, Schoenefeld, Brandenburg Region, Germany","shortName":"Steigenberger Airport Hotel Berlin","displayName":"Steigenberger Airport Hotel Berlin, Schoenefeld, Brandenburg Region, Germany","primaryDisplayName":"Steigenberger Airport Hotel Berlin","secondaryDisplayName":"Schoenefeld, Brandenburg Region, Germany","lastSearchName":"Steigenberger Airport Hotel Berlin"},"essId":{"sourceName":"LCM","sourceId":"57232524"},"coordinates":{"lat":"52.364089","long":"13.512011"},"hierarchyInfo":{"country":{"isoCode3":"DEU"}},"cityId":"6051563","hotelAddress":{"street":"Willy-Brandt-Platz 3","city":"Schoenefeld","province":""}},{"@type":"gaiaRegionResult","index":"8","gaiaId":"6275075","type":"POI","regionNames":{"fullName":"Kurfürstendamm, Berlin, Germany","shortName":"Kurfürstendamm","displayName":"Kurfürstendamm, Berlin, Germany","primaryDisplayName":"Kurfürstendamm","secondaryDisplayName":"Berlin, Germany","lastSearchName":"Kurfürstendamm"},"essId":{"sourceName":"GAI","sourceId":"6275075"},"coordinates":{"lat":"52.50170664214879","long":"13.321330888105717"},"hierarchyInfo":{"country":{"name":"Germany","isoCode2":"DE","isoCode3":"DEU"}}},{"@type":"gaiaRegionResult","index":"9","gaiaId":"6287096","type":"NEIGHBORHOOD","regionNames":{"fullName":"Ocean Pines, Berlin, Maryland, United States of America","shortName":"Ocean Pines","displayName":"Ocean Pines, Berlin, Maryland, United States","primaryDisplayName":"Ocean Pines","secondaryDisplayName":"Berlin, Maryland, United States","lastSearchName":"Ocean Pines"},"essId":{"sourceName":"GAI","sourceId":"6287096"},"coordinates":{"lat":"38.395393","long":"-75.155739"},"hierarchyInfo":{"country":{"name":"United States","isoCode2":"US","isoCode3":"USA"}}}]}

I re-formatted the JSON you posted by using the Preformatted text button (</>) in the forums toolbar. That removes the smart quotes. Now you can copy that entire wall of text and paste it into https://codebeautify.org/jsonviewer to view the JSON tree. If you click on a property name on the right side of the window, it will show the path to that property at the top. Like this:

If you need to know more about how to parse JSON, you can watch my tutorial video here: API JSON Tutorial (Video)

Ok thanx…i will watch ur video

(its a different question)hey i got this array of 5 elements instead of object…i want the city_ufi

I explain that in the video around 21:54: API JSON Tutorial - YouTube

If you have trouble, post a screenshot of your blocks.

1 Like