Closed virtadpt closed 9 years ago
That's bizarre, but it seems like Rails may be seeing a huge single string being POSTed, not valid JSON data. Are you posting with content type JSON and a payload of the data you showed?
Content-type: "application/json"? I don't know. I'll check tonight after work.
Payload of the data I showed? Yes, that was a cut-and-paste of the POST body right out of my application.
I'm fairly confident that you're not sending a valid JSON POST request.
curl -H "Content-Type: application/json" -X POST -d '{"key":"value","key2":"value2"}' http://localhost:3000/foo/bar
I've added this header to my POST request. I'll give it a try later today.
It works! Please don't close this ticket out until I've had a chance to write the wiki page describing how to use the Webhook Agent.
Created a wiki page which explains how to use it: https://github.com/cantino/huginn/wiki/Using-a-Webhook-Agent-with-external-software
Thanks for writing this!
Information POSTed into a Webhook Agent must be correctly formatted JSON. All HTTP requests made to a Webhook Agent must have the Content-Type: application/json HTTP header, otherwise you'll get bizarre results.
This isn't technically true. Rails also supports POSTs in form encoding with a syntax for describing nested structures, but JSON is probably easier.
To get some data into Huginn (a list of URLs, specifically), I'm trying to take advantage of the fact that passing a JSON array to the payload_path option would result in the emission of an event for every element in the array. Here's the POST body I'm using:
However, a JSON array is not being received by WebhookAgent. I'm not entirely sure what you'd call this:
I'm not sure if I'm misusing the payload_path option, or if JSON parsing isn't working correctly, or what. I can post a copy of my WebhookAgent if necessary.