Webhooks JSON response is escaped

Having the webhook:

{ 
    "eventName": "get_connections",
    "url": "http://transport.opendata.ch/v1/connections?from=Basel&to=Bern&fields[]=connections/from/departureTimestamp&limit=6",
"requestType": "GET"
}

I receive an escaped JSON-String:

got json:"{\"connections\":[{\"from\":{\"departureTimestamp\":1426109220}},{\"from\":{\"departureTimestamp\":1426110120}},{\"from\":{\"departureTimestamp\":1426111020}},{\"from\":{\"departureTimestamp\":1426111920}},{\"from\":{\"departureTimestamp\":1426112820}},{\"from\":{\"departureTimestamp\":1426113720}}]}"

Code snippets:

Spark.subscribe("hook-response/get_connections", gotConnectionData, MY_DEVICES);
//...
Spark.publish("get_connections");        
//...
void gotConnectionData(const char *name, const char *data) {
        Serial.println("got webhook data for connections");
        String str = String(data); 
        Serial.print("got json:"); 
       Serial.println(jsonData); 
}

As a result, my json parser can not interpret the result. Is this an error on my side or with the webhooks?

1 Like

Hi @Coffee

Hmmm… That seems less than ideal… I’ll add a bug for this and get back to this thread when it’s fixed.

Thanks!
David

3 Likes

I’m also experiencing this with a Content-Type text/plain resource. The entire response is quoted, and each quote and backslash inside the response is escaped.