Thunkable unable to recognize JSON received from API

Ah sry, that was a typo. In reality it was

image

so if you paste exactly what the server is returning into the test blocks above, does it work? If so, it’s a web server problem. If not, it’s a web_api problem.

I suggest displaying labels with the server response, status, and error while testing. You might learn something.

1 Like

There is nothing wrong. Response shows the text I gave, status shows 200 and error shows undefined.

Another thing, it seems the error is on this line

image

1 Like

That pink block will definitely cause a crash if you’re asking for a property that doesn’t exist in your object.

2 Likes

Does TEST not exist? {“TEST”:“LMFAO”}?

I agree that it should. And when I set a variable to those values, it works fine. So what blocks are above the small screenshot you posted? Show me where you set the variable “name”? And show me the label with the unprocessed server response? Or PM me a link to the server or to the project so I can see it myself, if you like?

1 Like


I’m just printing it to a label I already had set up

image

1 Like

your last picture doesn’t show the server response?

No it does, it is just what it looks like before it.
Just change the code to
image
And it should print there

I can’t run your code. Even if I wanted to recreate it all out from the screenshots, I can’t actually see the full URL you’re using in that join block, so there’s no way I can recreate it here.

1 Like

The url is https://SpottedPureAnimatronics.ismailatrepl.repl.co/loginl

1 Like

Another thing, I don’t know why, but if I list out all the all the properties it gives me an infinite list starting from 0 like [0,1,2,3,4,5] etc…

1 Like

I remixed your project. Thunkable is getting ‘null’ for response when I try it, although when I paste the URL into a browser I get the text you listed. I also tried with curl, and I see the server sending a 200 status, so I’m not sure why that’s not getting through Thunkable either.

I wonder if you need to get the server to send a different content type? Can you get it to report a content-type of application/json instead of text/html ? I’m not sure this is the problem, but it’s my best guess.

2 Likes

When you get a response from the server it will most probably be in JSON format. Thunkable sees JSON as formatted text and cannot work with it.

To use the get property block first convert the JSON to object then use the object blocks. Use get object from JSON for Thunkable to treat at as an object.

2 Likes

You can see an example of how to use the get object from JSON block at the 17:49 mark in my tutorial video:

2 Likes

The OP did try create object from json. His server seems to be offline now, so I can’t verify that, unfortunately.

@catsarisky Hi, I could use some more help. I have a chunk of data to send so I decided to try converting it to a list and then sending, following the instructions from here API results into a List Viewer. For some reason is still crashes at the exact same block, tho I have no idea why. It is successfully converted to an object but I can’t do anything with it without having it crash. I wish Thunkable would give error statements instead of just crashing. Anyways here is the block:

I suspect it is the pink block.

1 Like

If you turn it on, we could confirm that thunkable is not reading the server response correctly.

Did you see my question about content-type?

update: still 500 server error.
Update #2 - now getting “hi” - which is not JSON format.

Oh, ok. So do you need help with anything at this point? Lots of us have experience with getting JSON from servers and processing it successfully, so if we don’t need to debug your specific problem (which is probably only yours), we won’t! :slight_smile:

1 Like