Android Question GET request on Phillips Hue API V2

StephanP82

Member
Licensed User
Longtime User
I'm developing an app to control my Phillips Hue lights. I'm currently using API V1 for this. It is deprecated and will be replaced by API V2. My problem is that I don't know how to use the new GET and POST requests with B4X. Using the old API I got the list of lights with:
B4X:
Dim JobDoc as HttpJob
JobDoc.Initialize("", Me)

JobDoc.Download("https://192.168.178.34/api/" & UserID & "/lights")

Wait For (JobDoc) JobDone(JobDoc as HttpJob)
...

The new API requires authentication in the request header. The migration instructions say:
The combination of the new endpoint with the new header results in the following equivalent request on V2:
HTML:
curl --insecure -H 'hue-application-key: <appkey (== username)>' -X GET 'https://<ipaddress>/clip/v2/resource/light'

Does anyone know how to handle this with B4X? Thanks in advance.
 
Last edited:

StephanP82

Member
Licensed User
Longtime User
I figured it out myself. Once you know it, it's very simple:
B4X:
JobDoc.Initialize("", Me)
JobDoc.Download("https://192.168.178.34/clip/v2/resource/light")
JobDoc.GetRequest.SetHeader("hue-application-key", UserID)
Wait For (JobDoc) JobDone(JobDoc As HttpJob)
...
Thanks anyway
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…