WebAPI troubles, it can't show my JSON

This is my JSON below:

[{“Id”:1,“Machinename”:“CNC”,“Temperature”:“120”,“Operating_Time”:“2’20”,“Designed_RPM”:“240”,“Current_RPM”:“200”,“X”:“20”,“Y”:“15”,“Z”:“12”}]

I use C# to make it and the URL is “https://localhost:44XXX” or “https://192.168.X.X:44XXX”.

This is my blocks in my project:

I want to know why the information from JSON can’t show in my app.

1 Like

I try every way which I know to {get property} like:

[1].Machinename
Id
CNC.Designed_RPM(because my URL is:https://localhost:44XXX/XXX/CNC)

But none of them is worked.

1 Like

It’s not valid JSON the way it’s written above. Your quotes are special characters. If I replace them with standard quotes ("), then it is valid JSON. That may not be why you’re having problems but it did prevent me from understanding the issue at first.

Once I replaced the quotes, the parsing blocks you used above worked properly (e.g. [1].Machinename returned “CNC”).

Are you checking the green error block value to make sure you’re not getting an error?

2 Likes

The Discord forum app is the one replacing normal quotes with special quotes. Authors need to include quoted strings in </> (back ticks) to prevent the forum app from replacing them.

1 Like

the error block is “null” just like response

and the quote is my typing mistake, this is the screenshot of my JSON below:

If I replace all of the quotes in your first post with normal quotes ("), these blocks return the value “CNC”:

If I do not replace the quotes, I get the value “null”.

Here’s a link to the project: Thunkable

1 Like

Are you testing this on a mobile device? If so, are you able to ping https://192.168.X.X:44XXX from that device? I wonder if your device can’t reach the server.

2 Likes

@kevin964444eu2ayd
I got the same results with this


Which is a slightly different way but gives the same result.

1 Like

@tatiang @muneer
the value in JSON need to change all the time, if I want to change it in variables, I need to make it happen in person.

Is there any solution to get the data by using WebAPI block(the purple one)?

@tatiang Yes, It’s a app for mobile. My mobile can get the server. It takes me lots of time to fix it and it works now. I can open the JSON by google chrome.

1 Like

Can you elaborate?
Give an example of what you mean. Do you mean the keys (“id”, “Machinename”,…) keep changing? Or do you mean you might have a list of more than one item?

1 Like

I use C# to get the CNC’s data. The number in my JSON like “RPM,X,Y,Z” will change with the operating machine.
I haven’t finish this part but I think the Web_API may work. This is why I need the Web_API/Get/response to do it.

I think the main problem is that “my Web_API’s response/status/error all are null now”.

1 Like

It’s fine if the API property values change. We’ve shown you the correct blocks to use for the JSON response you are getting.

So if you are still getting “null” responses then there is a problem with your server or server address. I don’t know how to help you with that.

If you had a way to serve the data externally and could provide a url we could access, we could test this further for you.

2 Likes

Can you explain where you are getting it from? Are you testing from Thunkable platform in the computer or from the mobile?

As far as I know you will not be able to reach your internal/local JSON server from the computer but you will be able to reach it from the mobile.

Also, most probably you do not have a security server/service running internally so you should use http:// not htpps://.

1 Like

I try it both. Both of them didn’t work.
I’ve tried the http:// before, I didn’t get the response as well.

I can open the url by Google Chrome in computer and from the mobile. Does it mean that I can reach the server?

1 Like

When you click preview button or Live Test menu option, Thunkable web page opens a Modal page which is, most probably, an iFrame or an AJAX xmlHTTP component which will try to connect to your local server from the Thunkable server and therefore it fails.

Your only option is to test using the Thunkable Live App in your phone which will use your phone’s connection to reach your server.

1 Like

@muneer @tatiang
Thanks for your helping me! You guys are so kind that I feel so grateful to you.
l’ve already solve this problem. It takes me to much time to understand and fix it.

Hope you guys having a great day.

2 Likes

Glad to know you fixed your issue.

Happy Thunking!