Best way to fetch data from an API

Greetings,

What would be the best way to fetch and push data to an api ? i have so far like 30 api calls and on one thread i need to call 12 of them to get the data and update the database, then the rest to push data to the api.

I tried calling an httpsocket but i get errors.

Should i create an socket for each call or have a socket and update the data within while calling ? how should i handle the data in it ?

the process is the following :

1 Connect to API
2 Fetch the 12 tables
3 add them to arrays for processing
4 process the data and update the local database .

in all those 4 steps i have to update the interface as well so i use threads and timers but it seems that the combination is not the best due to the call delay .

Thanks in advance

is there a way to have this in a method or a thread and to fetch them ? and what would be the conversion from this to Xojo.Net.HTTPSocket ?

[code] dim EmergencyAPI As String = "http://localhost/api/V1/Users
dim EmergencyResponse As String

SyncSocket.SetRequestContent(EmergencyAPI, "JSON")
SyncSocket.SetRequestHeader("accept", "application/json")
SyncSocket.SetRequestHeader("content-type", "application/json")

EmergencyResponse = SyncSocket.Post(EmergencyAPI, 15)
EmergencyResponse = DefineEncoding(EmergencyResponse, Encodings.UTF8)

[/code]

It seems that when i do same thing into the new socket i get all kinds of errors and it not always work .

The new one can be used dynamically it it`s mandatory to use the PageReceived and all the details in the Socket ?

In this case i have to do one socket for each call ?

Thanks .

Use the events. Make a subclass add super Xojo.Net.HTTPSocket

Set parameters on an instance then let the pagereceived event handle it. Show on the UI, set parameters again and make a new call.

[quote=355065:@Derk Jochems]Use the events. Make a subclass add super Xojo.Net.HTTPSocket

Set parameters on an instance then let the pagereceived event handle it. Show on the UI, set parameters again and make a new call.[/quote]
Thanks for that,

So you mean I should do like a super class and reuse the parameters as dynamic, I think I did something like this but instead I put all the calls in the same super class and now I get errors like [quote]A request is already in progress.[/quote] , if you could please provide an example of that would be great, all what I found on the forums and data was one record only and one call but I Guess that is the purpose of reusing the socket

What is the build target you need this for?

Windows, Mac , IOS

The idea is to have a master pc with a SQLite DB and the clients which are 4 Desktop clients and then for each desktop client 4 iPads and all those they have to sync between them

So Master PC has all the data , it serves the data to the 4 Desktop clients and then each desktop client has an iPad paired to it to sync data.

Workflow :

Remote Location : iPads are used to check assets , no internet connection available; then they reach to the office, they have to sync the data with the Desktop Client which would be the supervisor pc, then that pc will come to the main office one a week or more frequently and update data on the master pc.

due to the connection limitations that is the only way.

All the units run SQLite Database as storage engine.