Hi.
I need help with this, please.
This is my code to get a json string that works ok on my local network if i previously logged in locally (In Chrome for example).
But in order to work without login in a browser i need to set a cookie first. How can i do that?
How can i set a Cookie then save it and reuse in every next downloads?
This is my current code:
This is the API documentation in order to login with cookies:
Now we can execute with cookie:
Thanks for advise!
I need help with this, please.
This is my code to get a json string that works ok on my local network if i previously logged in locally (In Chrome for example).
But in order to work without login in a browser i need to set a cookie first. How can i do that?
How can i set a Cookie then save it and reuse in every next downloads?
This is my current code:
B4X:
Dim job As HttpJob
If Not (job.IsInitialized) Then
job.Initialize("GET_DEVICES", Me)
End If
job.Download(Server & "/api/v2/devices/1")
job.GetRequest.Timeout = 6000000
This is the API documentation in order to login with cookies:
B4X:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"form": true, "login": "admin", "password": "admin", "keepme": false, "default_ui": 1}' 192.168.0.62/api/v2/login -c cookie.txt
Now we can execute with cookie:
B4X:
curl 192.168.0.62/api/v2/devices/1 -b cookie.txt
Thanks for advise!
Last edited: