[SOLVED]Control LEDs over the 'net - ERROR - "ok": false, "error": "Variable not found"

Hi All,

I got stuck with the example code (Control LEDs over the 'net).
I have tried many things over the last 24 hours but still no results.

Here’s a overview of the problems I have encountered:

1. HTML file doesn’t load the form but shows just the plain text.
Yes, I did add my own ID and Token taken from the Build section
Many times indeed. Also after reset Token, And restart to factory settings.

2. When copying the API into the browser I get the following error:

{ “ok”: false, “error”: “Variable not found” }

Any help, tips or tricks would be much appropriated.

Copying this definitely worked for me:

  <form action="https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here" method="POST">
    Tell your device what to do!<br>
    <input type="radio" name="args" value="on">Turn the LED on.
    <input type="radio" name="args" value="off">Turn the LED off.
    <input type="submit" value="Do it!">

What API exactly did you copy into the browser? This stuff?

curl https://api.particle.io/v1/devices/0123456789abcdef/led \
  -d access_token=123412341234 \
  -d params=on

If so, then yes, that doesn't work. To trigger functions you'd need to make a POST request, whereas your browser normally only makes GET requests. That's why it's reporting it didn't find a variable, since those use the GET requests with the same syntax.


Hi Moors,
Thanks for your reply.
And that from another Limburger!!

Tried it again, same (no) result.

I’ve copied the API address from within this piece of code (after ,form action=") into the browser.
With my personal ID and token. Again same (no) results.

Any other suggestions I should look at?

Im sure at one point you will ask me about my copy paste skills with regards to my ID and Token but Im sure I got that part sorted!


It's a small world :wink:

When you say "no result", what exactly do you mean? Is the website displaying something incorrectly, or do are you not able to toggle the LED?
Do you see this at least?

The same reason as above; you're doing a GET request whereas you should be making a POST request instead.

we'll get to that in a bit, don't worry :stuck_out_tongue_winking_eye:

Hi @jaapdemaat

You can't POST in a browser by just typing in a URL--it doesn't work that way.

You can POST from curl using the right syntax or you can POST from a web page form with a form action or by using AJAX, but not by typing or cutting and pasting into the URL box.


Yes small world indeed!

The browser simple slows the code itself (like in a text editor) and doesn’t load the form as you showed me above.
Which of course results into not being able to toggle the LED.

I guess we’re going into the copy paste aspect of my skills… :grin:

ps: Can I see your singing Tesla Coil anywhere online? Sounds amazing!

Hi @bko
Thanks for your reply but as I got rather desperate last night and start trying everything :smile:
Im aware that this isn’t the way forward. The issue is within the html code as it doesnt load proper in the browser.
thanks, j

1 Like

Sounds like it. Could you use the code I posted above, put that into a text file, swap the credentials, and then make sure to save it as a .html file?
There's no reason why it shouldn't work, other than human error or a crappy browser.

In regards to the Tesla coil, yup you can over here.

1 Like

Hmm, you might not want to put your credentials out in the open like that. PM them next time if you want me to take a look at them.

Seeing as you’re using oSX, would you mind trying a different text editor, this might have something to do with it: http://stackoverflow.com/questions/14439513/browser-shows-plain-text-instead-of-html-in-mac



Thanks, have deleted the Post, thought it wouldn’t be a massive issue if I change my Access token later.
New here so I couldnt find PM anywhere.

Will have a look at the osx text edit issue and let you know if it would solve the it.



Problem: OSX Textedit software.
Instead used: TextWranger (which is free)

Someone at Particle should update the Guide as Im sure other people will have the same problem.

@Moors7 You are a star!
Thank so much for helping.
Next time Im in Limburg I buy you a drink!


Glad to hear you’ve got it working!

OSX always messes things up… :wink: Still better than Windows though… :’(

Let me/us know if you’ve got any further issues, and we’ll see what we can do to help out.

1 Like