Maker API - Code Example

I want to send On\Off commands via Maker API from a web page.
Maker API works and these commands work.
http://192.168.0.200/apps/api/2871/devices/2459/off?access_token=12345
http://192.168.0.200/apps/api/2871/devices/2459/on?access_token=12345

But I can't figure out how to do these with a submit from an HTML page so that I don't see the JSON results. Always get an error - Request Header Fields Too Large.

I believe the command I need is something like this.
<button type="submit" "onclick='location.href =http://192.168.0.200/apps/api/2871/devices/2459/on?access_token=123' "; value=On />

Can anyone post a working example or point out where I am going wrong?

Thanks!

1 Like

Something here is weird... :thinking:

Yes, check the quotation marks!

<button type="submit" onclick="location.href='http://192.168.0.200/apps/api/2871/devices/2459/on?access_token=123'" value="On" />

2 Likes

Thanks, that was very helpful. To use in my code I just had to quote it again. I found out that triple double quotes was a thing so with that I'm able to do this.

myHTML = """<button style="height:30px;width:30px;color:red" type="submit" onclick="location.href='http://192.168.0.200/apps/api/2871/devices/2459/on?access_token=12345" value="On" />"""

Now I just need to figure out how to not display the JSON response.

2 Likes

Markup, which is what is available to us in our posts here, can also mess with quotes and other special characters as well... Nice work @Jost in getting something for @garyjmilne to use.

1 Like

Send it using JavaScript and an XmlHttpRequest object.

3 Likes

Thanks, took me a couple of hours but I got a very basic working example going. Time to noodle on it now.

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.