I am trying to create an application using VB in Visual Studio 2010 to remotely control a Spark Core. To test, I am using the “control an LED over the net” example. So the command is:
“curl https://api.spark.io/v1/devices/123456789/led -d access_token=abcdef123456789 -d params=l1,HIGH”
Putting this in console2 works so I know the core is set up correctly…
In VB, the commands are:
"Dim addbase as String
addbase = “https://api.spark.io/v1/devices/123456789/led -d access_token=abcdef123456789 -d params=l1,HIGH"
Dim client As New WebClient()
Dim res1 As String
res1 = client.DownloadString(addbase)”
But this gives rise to a 400 error. Replacing the command line with:
works and gives a sensible return value.
I have a suspicion that the error is caused by Visual Studio replacing the spaces in the command with the URL encoded %20.
Grateful if anyone can provide any help.