Web hooks GET / PATCH

So I’m trying to interface with an API but I’m starting to tear my hair out trying to figure out this web hook business. I’ve succeeded with making curl calls that are registered and responds correctly but I cannot for the life of me figure out web hooks. So I would love to get some input.

Let’s start with the GET part, so I have a API which I can call using the url and a (Authorization: Bearer TOKEN) what I get back is a JSON formatted string which includes for example humidity and the value of it. So what I wanted to do is solve the riddle of how to extract the humidity data from the JSON response and being able to use it via the spark core.

Curl request example:

curl -H "Authorization: Bearer XYXXXX" "https://api.randomcompanyexample.com/v1/readings/?sensor_type=2&device=XYZZZ&limit=1"


  "meta": {
    "limit": 1,
    "next": "/v1/readings/?device=XYZZZZ&sensor_type=2&limit=1&offset=1",
    "offset": 0,
    "previous": null,
    "total_count": 3599
  "objects": [
      "created": "2015-03-25T16:25:20",
      "device": "/v1/devices/XYZZZ/",
      "id": XYZZZZ,
      "resource_uri": "/v1/readings/XYZZZZ/",
      "sensor_type": {
        "id": 2,
        "name": "temperature",
        "resource_uri": "/v1/sensors/2/"
      "value": "20.4965267181"

Second problem is having the spark core issue a PATCH command via the web hooks, this is to trigger for example a device to turn off/on or change modes via the HTTP calls from the Spark.

Curl example:

curl --request PATCH --data-binary '{"current_mode":"\/v1\/modes\/3\/"}' -H "Authorization: Bearer XYZZZZ" -H "Content-Type: application/json; charset=utf-8" https://api. api.randomcompanyexample.com.com/v1/locations/XYZZZ/

No response is given but after “modes” the number 3 sets the mode of the device, so I want to be able to send 1,2 or 3 as a variable from the spark core.

Hey @felixekman, sorry this wasn’t responded for some time…

How is it going? Did you managed to resolve it?

@kennethlimcp No problem! Nah, I haven’t gotten it to work sadly. Haven’t found any way to do PATCH from the spark core or a request with extra headers and parsing the JSON object.

Hmm… I’m not so familiar with webhooks but for extra headers maybe here: http://docs.spark.io/webhooks/#webhook-options-headers

@kennethlimcp That could possibly fix the request problem, but I can’t seem to get it working. Also, it won’t solve the PATCH issue.

1 Like

Let me try and see how things go :slight_smile:

Any success? fingers crossed

There’s some issue with the webhook via Spark-cli and it should be looked into hopefully this coming week/next!