Android Question How to enter a curl command as an HTTPS request

Colin Evans

Active Member
Licensed User
Longtime User
Hi

I want to retrieve JSON data from my electricity supplier, they have an API which I have a API_Key for but the examples they give are using the CURL tool at the CMD prompt, something I can't get my head around.

In some of my previous amateur apps I have issued a browser request which then returns the JSON data which I can work on but I don't know how I would convert their example to a simple HTTPS:// request

Below is their example with the API_Key removed

curl -u "API KEY" "https://api.octopus.energy/v1/electricity-meter-points/1460001714995/meters/15P0459914/consumption/"

I have tried the company but I think due to the Covid situation I don't think any one is working in their support team

Don't know if someone can help but its worth a shout out, thanks
 

OliverA

Expert
Licensed User
Longtime User
1) Please start using code tags (either through editor or by using [code][/code] tags)
2) In the first example, you are using JobDone (not cool anymore). The second case, you are using Wait For (the new, correct way). With Wait For, your parsing code needs to go
B4X:
If job.Success = True Then
        Log(job.GetString)
    Else
        Log(job.ErrorMessage)
    End If
Where the Log(job.GetString) is
3) Please review https://www.b4x.com/android/forum/threads/b4x-okhttputils2-with-wait-for.79345/#content

Update:
4) Technically, this was a new question and should have been posted as a new thread (new question = new thread).
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Sorry for the syntax etc, thank you for the points you put forward which I have implement and now working perfectly, many thanks
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…