Hello colleagues
I have created a REST API with Visual Studio 2022, which connects to a local SQL Server database and creates a JSON response from the information, when executed locally, my browser looks like this in the following image:
I want to consume this REST API from B4A, I do it in the android emulator but even though my REST API is working perfectly it shows me an error saying that there is no local connection at the localhost address (127.0.0.1:5056 ).
View B4A log image
Here is my B4A code:
I made a Desktop application consuming the REST API and it works great.
What then should I do to be able to consume this API from the Android Emulator?
I thank you very much if you can help me.
I have created a REST API with Visual Studio 2022, which connects to a local SQL Server database and creates a JSON response from the information, when executed locally, my browser looks like this in the following image:
I want to consume this REST API from B4A, I do it in the android emulator but even though my REST API is working perfectly it shows me an error saying that there is no local connection at the localhost address (127.0.0.1:5056 ).
View B4A log image
Here is my B4A code:
B4X:
Dim j As HttpJob
j.Initialize("", Me) 'name is empty as it is no longer needed
j.Download("http://localhost:5056/Persona")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
'The result is a json string. We parse it and log the fields.
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim root As List = parser.NextArray
Dim data As List
data.Initialize
For Each colroot As Map In root
Dim id As Int = colroot.Get("id")
Dim nombre As String = colroot.Get("nombre")
Dim telefono As Int = colroot.Get("telefono")
data.Add(Array(id, nombre, telefono))
Next
DGVJson.SetData(data)
B4X:
I made a Desktop application consuming the REST API and it works great.
What then should I do to be able to consume this API from the Android Emulator?
I thank you very much if you can help me.