IFTTT Web service test

SBSP

Senior Member
Joined
Sep 7, 2007
Messages
667
Reaction score
16
Has anyone ever created an JSON based web service that will be accessed by IFTTT ?
I'm struggling a bit with something very simple.

I created an action that will integrate with my own personal service.
From the IFTTT platform console they give you a test button that will perform a series of test against your web service.
The test involves sending valid and invalid data to ensure you handle the request properly.

All of the tests are green except for one "with invalid records" When the test is conducted it shows you the request including the HTTP headers along with the response from your web service.

So the test they send with the so called "Invalid Records" look like this.

Code:
Request
    Method: Post

Headers
    Accept: application/json
    Accept-Charset: utf-8
    Accept-Encoding: gzip, deflate
    User-Agent: IFTTT-Protocol/v1
    IFTTT-Test-Mode: 1
    IFTTT-Channel-Key: zCB-0LQiJ3GYcflWARd2svst8sbysCJAm5WTv4GhssI3vOIaawxtfdBWDE6wHn5w
    IFTTT-Service-Key: zCB-0LQiJ3GYcflWARd2svst8sbysCJAm5WTv4GhssI3vOIaawxtfdBWDE6wHn5w
    X-Request-ID: efe4938e8d0c4e0bb2a7b000f080772a
    Content-Type: application/json

Body

{
  "actionFields": {
    "var1": "87",
    "var2": "value 2",
    "fstate": "1"
  },
  "user": {
    "timezone": "America/Los_Angeles"
  },
  "ifttt_source": {
    "id": "91176b1c6c2aefc8",
    "url": "http://example.com/91176b1c6c2aefc8"
  }
}

But I dont see where invalid records are sent, all of them are actually correct. In fact when I compare them with the Valid request test below. They seem to be exactly the same, Unlees I'm not spotting the difference.

FYI: the ID for ever changes, I dont ythink it's because of the ID.

Code:
{
  "actionFields": {
    "var1": "87",
    "var2": "value 2",
    "fstate": "1"
  },
  "user": {
    "timezone": "America/Los_Angeles"
  },
  "ifttt_source": {
    "id": "3d9a229763e440ea",
    "url": "http://example.com/3d9a229763e440ea"
  }
}
 
Have you tried using postman and hitting your service with the invalid request to see what actually fails?
 
I found the problem, was actually so simple. It's because I didn't understand the "test". You create a test response on your endpoint and IFTTT will mimmick the JSON data back to your endpoint where the actual trigger happens. Problem was I copied the valid test settings onto the Invalid test settings. So when it requested "Invalid" data it actually requested valid information.

The invalid data test is for when your endpoint expects say numbers only , which then allows you to reject the response with the correct HTTP error code. If not IFTTT will eventually disable your applet if the user had to provide unusable data and your web service just cuts out with badly implemented error handling.
 
All done and working like a dream!
IFTTT service development is a very nice way to learn how to make use of REST web services and oAuth. Learnt lots in no-time.


2.png
3.png
 
Top
Sign up to the MyBroadband newsletter
X