· Mar 4, 2016 2m read

RESTful API Call From Cache to Electron

RESTful API Call From Cache to Electron

Tom Fitzgibbon | Multidata | 212-967-6700 x537 |

Summary: Simple Blink Tutorial for Electron Device from Cache

Electron device is a tiny ARM processor ($40-$60) that connects to Particle’s world wide leased 2G/3G network (about $3/mo) and runs off an included LiPo battery. Using Cache’s %Net.HttpRequest you can send/receive data, control hardware and read sensors.

Step by Step (about 1 hour)

1) Get the Electron from

2) Set up the Electron from

3) Install an LED and resistor from setup instructions.

4) Test with using their code for “Web-Connected LED”.  You get your access_token from Settings and device number from Devices in Build and substitute in their code.  Edit the code to make sure you can light the LED from a browser before moving to step 5.

5) Setup an SSL configuration in your Cache via the SMP (System Management Portal) in Security/SSLTLS configurations. Just create a new SSLTLS configuration by entering a name (like TLS) and saving.

6) Run the following Cache code from an internet connected Mac or PC after substituting your access_token, device number and on/off in args. Do ^LED1 from Cache terminal.

LED1 ;simple blink test with Cache
 Set httprequest=##class(%Net.HttpRequest).%New()
 Set httprequest.SSLConfiguration="TLS"
 Set httprequest.Https=1
 Set httprequest.Server=""
 Do httprequest.InsertFormData("access_token”,”your access token here“)
 Do httprequest.InsertFormData("args”,”on”)
 Do httprequest.Post("/v1/your device number here/led")
 Do httprequest.HttpResponse.OutputToDevice()

7) You can also test from a Linux Curl command:
curl device number/led -d access_token=your access_token -d args=on

Discussion (0)0
Log in or sign up to continue