I was hoping someone could tell me how to structure a HttpWebRequest in VB.NET to be able to retrieve information using the following API: https://api.developer.lifx.com/docs/list-lights
The code I am interested in replicating is here (in Python):
import requests
token = "YOUR_APP_TOKEN"
headers = {
"Authorization": "Bearer %s" % token,
}
response = requests.get('https://api.lifx.com/v1/lights/all', headers=headers)
A cURL version of this can be seen here:
curl "https://api.lifx.com/v1/lights/all" \
-H "Authorization: Bearer YOUR_APP_TOKEN"
My question is: how do I do this in VB.NET? Would a HttpWebRequest be the way to go? If so, could you please assist me by providing some example code?
I am hoping to retrieve a list of all my lights.
That is correct; A HTTP Request would be the way to go. The python sample code you provided mentions headers which can also be done using a
WebHeaderCollection
. One other way to do it is using a web client.Web client (No headers)
With Headers using WebRequest