Webhook response always return "\n"

I am a new user of the Particle and I created a webhook to get some information from an api which gives real-time schedule of a bus at a certain stop. Here is the url I used in the webhook:

https://truetime.portauthority.org/bustime/api/v3/getpredictions?key=XjsnC9eVJZRiHJKe78YZdiRyJ&stpid=1174&rt=71D&rtpidatafeed=Port%20Authority%20Bus

The raw data returned is in JSON format:

        {
          "bustime-response": {
            "prd": [
              {
                "tmstmp": "20180129 18:41",
                "typ": "A",
                "stpnm": "Fifth Ave at Craig St (nearside)",
                "stpid": "1174",
                "vid": "5372",
                "dstp": "3170",
                "rt": "71D",
                "rtdd": "71D",
                "rtdir": "OUTBOUND",
                "des": "HAMILTON WILKINSBURG",
                "prdtm": "20180129 18:47",
                "dly": "false",
                "dyn": "0",
                "tablockid": "071D-196",
                "tatripid": "10760",
                "prdctdn": "5"
              },
              {
                "tmstmp": "20180129 18:41",
                "typ": "A",
                "stpnm": "Fifth Ave at Craig St (nearside)",
                "stpid": "1174",
                "vid": "5663",
                "dstp": "22967",
                "rt": "71D",
                "rtdd": "71D",
                "rtdir": "OUTBOUND",
                "des": "HAMILTON WILKINSBURG",
                "prdtm": "20180129 19:11",
                "dly": "false",
                "dyn": "0",
                "tablockid": "086 -306",
                "tatripid": "10764",
                "prdctdn": "29"
              }
            ]
          }
        }

I use a response template to get the value of “prdctdn” in the first array, which is
{{bustime-response.prd.0.prdctdn}}

But in the Event of the console, the hook response is like:
{"data":"\n ","ttl":60,"published_at":"2018-01-30T00:14:07.523Z","coreid":"particle-internal","name":"hook-response/busgazer/0"}

Apparently it is not the data I want. I have no idea how to solve this problem, am I using a wrong response template?

Let me ping someone that might be able to help, @rickkas7 are you able to assist?

Thank you KyleG! I have figured it out. It seemed that the api returned data in XML format and the Cloud iwas unable to parse it. I added “format=json” to the url to ask for data in json format and now it works perfectly.

2 Likes