Android Question Help with JSON API call

spv4u

Member
Licensed User
Longtime User
Hi all I'm struggling with getting some code to request and parse a JSON even after reading lots of examples.

I have the following variables set

Dim dataURL As String = "https://hostingserver.com" (unable to publish correct url publically)
Dim BranchID As String = "22"

I need to send the URL the required branch ID as part of the request which should look like {"branchid": "22"}

I should then get back a JSON to parse in the following structure

Response
JSon{
BranchId
Order: [
{
SaleOrder ID
CustomerName
VehicleReg
CollectionBay
Status
},
{
SaleOrder ID
CustomerName
VehicleReg
CollectionBay
Status
}
]
inStoreCollection: [
{
SaleOrder ID
VehicleReg
CollectionBay
Status
},
{
SaleOrder ID
VehicleReg
CollectionBay
Status
}
]

Is anyone able to help me create the code so that I can call this from my Sub to request and parse the data so that I can then update the labels with the data returned

Thanks
 

spv4u

Member
Licensed User
Longtime User
Not sure why or if I have found a bug but I resolved the issue.

If I add the code

B4X:
StopService(HttpUtils2Service)

on the next line after job.release the app works fine, it appears that stopping the service and allowing it to restart means I get a read every time, if it is left running I get one clean record and the {} empty record returned every time after.

Thanks for your help today
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…