No JSON content when using IFTTT WebHooks?


#1

I’m trying to create a simple piston that takes the state from my Abode door sensors and converts them into proper (virtual) contact switch states in SmartThings.

I’ve got the WebHook created in IFTTT, configured to invoke the piston directly via the URL in the piston’s quick info box. It’s set to POST with application/json for the content type and a single ingredient called DoorName in the json body.

When the piston runs my if statement always evaluates to false. The statement is:

{$args.DoorName} is 'Garage Door'

The log shows:

Comparison (dynamic) null is (string) Garage Door = false

I’ve also tried

{$args.params.DoorName} is 'Garage Door'

and that doesn’t work either.

Based on past comments by @ady642 this should work. Is there a way to debug the POST body and see what IFTTT is actually sending? Anything that I’m missing?


#2

Try logging just $args by itself.


#3

So… I can’t even figure out how to insert a log statement. Total noob thing, I’ve seen code samples showing logging, but how do you insert that into the code?

Edit: Never mind, imported an existing thing that used logs and figured it out. How obtuse… having to select “location” as the action first. Weird.


#4

Ok, the logging shows me there is no JSON in the $args variable:

arguments: [param1:execute, param2::5be05cb9ba7adea84f503d0acde6afc4:, remoteAddr:addressremoved]

So… why?

Edit: AHA! I figured it out, and I’m an idiot (even though this is totally not clear). IFTTT’s Body field on the applet expects you to actually put in JSON. I thought it auto-generated JSON based on the Ingredient you stuck in. I changed the field to:

{“DoorName”:{{DoorName}}}

And now it works perfectly!


#5

Sorry, just got back to desk. :slight_smile: Glad you got it figured out. In the absence of a device, location is constant and that’s where you’d find Log and other tasks :slight_smile:


#6

These actions are available when selecting a device as well. Just scroll to the bottom of the actions.