Did You Know? Troubleshoot Custom Stream Connections

So you’ve decided that you want to use Initial State (because it’s the best, duh!) to view and manipulate your data, but you’re working with a device or system that can’t use our Python or NodeJS libraries. Or maybe you don’t feel like using those languages. Either way, it’s all good.

Did you know that there is an easy way to troubleshoot your stream requests? Whether you’re using our webhooks, cURL, or any form of an HTTP POST, you can double check the event names and values you’re sending. RequestBin makes this super easy.

Basically, RequestBin gives you a URL endpoint to use instead of “groker.initialstate.com/api/events” that then allows you to see what’s actually being sent in your request:

This response is the result of streaming through Google Apps Script (taken from my Pie Tops project). The original script looked a little something like this:

To have it stream to RequestBin, all I had to do was click the “Create a RequestBin” button and then copy-paste the URL I was given where¬†https://groker.initialstate.com/api/events?” used to be on line 19. Then my script looked like this:

And just like that I could make sure that my code was sending what I wanted it to! In this particular case, I needed to make sure that my actual values were being sent as strings.

One of the best use cases I can think of for RequestBin is working with any sort of Arduino-based device. For example, when first working with the ESP8266, I found that I had to use AT commands to interface with its WiFi capabilities (thank goodness this isn’t usually the case now). The hardest part was making sure that the HTTP request was being structured correctly.

// Build HTTP request.
String toSend = "POST /api/buckets HTTP/1.1\r\n";
toSend += "Host: "ISDestURL"\r\n" ;
toSend += "User-Agent:Arduino\r\n";
toSend += "Accept-Version: ~0\r\n";
toSend += "X-IS-AccessKey: " accessKey "\r\n";
toSend += "Content-Type: application/json\r\n";
String payload = "{\"bucketKey\": \"" bucketKey "\",";
payload += "\"bucketName\": \"" bucketName "\"}";
payload += "\r\n";
toSend += "Content-Length: "+String(payload.length())+"\r\n";
toSend += "\r\n";
toSend += payload;

Being able to tell that this was doing what I thought it was doing? SO important.

Well, that’s the basics of using RequestBin to troubleshoot. Hopefully this will help you build your next awesome project!

Leave a reply:

Your email address will not be published.

Site Footer