POST trouble and incomplete error message in dashboard

Hi, I am trying to send data via POST to a php website I made using the Advanced Webhook builder.

I can send the data to Thingspeak from the Webhook Builder without any trouble using the destination URL:
http://api.thingspeak.com/update?key=YOURTHINGSPEAKAPIKEY
and POST payload:
<<decdata>>

where <<decdata>> is &lat=31.1&lon=-106.1 (or something close)

I can also send data to my php page using curl from my desktop:
curl --data "&lat=31.1&lon=-106.1" http://MYSITE.com/track.php

But when I try send the data directly to my site using the Webhook Builder, using the destination URL:
http://MYSITE.com/track.php
and POST payload:
<<decdata>>

I get a ‘route error’ message in the dashboard. Unfortunetely, it is truncated:

Server sent HTTP status code 500 with body: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <tit

Is there a way to get the full error message? Also, is there something obviously wrong with my approach?

Hmm, we should probably strip out HTML from errors like that so we just get the message. I’ll make a note to the team.

I’m not sure why that wouldn’t be working. You could try using https://requestb.in/ to see the exact payload that is coming out of our cloud.

RequestBin is a great suggestion, but I do think it is valuable to be able to see any detailedbnerror message as it comes back from the server.

Yeah, sorry about that. Unfortunately the db field isn’t long enough with all of the HTML data. We’ll look into improving that soon.

Ok, requestBin shows me that using curl:
FORM/POST PARAMETERS

lat: 30.1
lon: -106.1

and using the dash:

FORM/POST PARAMETERS

None

I note that curl includes a field:
Content-Type: application/x-www-form-urlencoded

which is missing from the dashbord’s request. How can I use the dash to actually include those parameters?

Thanks for taking the time to read this.

Is this your own sketch? What does your sendMessage call in there look like?

It is my own sketch, but I am developing this remotely and the remote computer is shut down right now. I am using the simulate feature right now to resend data that came in earlier. The data did show up correctly in the dashboard, however:

&lat=31.7796837&lon=-106.4787569

Oh, so if you put that data into the simulate thing on the dashboard, then it does make it to your server correctly?

Oh I may be misunderstanding. I wonder if that missing header is the issue. You can add that in the advanced webhook builder manually so it matches up.

Well, yes, but I do get the error message that is truncated. If I malform the request completely, the error message changes to a 404…
Using the requestbin that was suggested, it seems likely that the missing form parameters are the culprit.

Ok, how can I add those missing parameters in the webhook builder? Trying to add them as ‘headers’ has no effect in requestbin.

One more datapoint:
It looks like the POST data is truly empty. I went and submitted to
http://posttestserver.com/post.php
Using the dashboard, which gives me:

Time: Thu, 19 Oct 17 06:01:03 +0000
Source ip: 23.253.159.55

Headers (Some may be inserted by server)
HTTP_HOST = posttestserver.com
HTTP_CONNECTION = keep-alive
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT = */*
HTTP_USER_AGENT = HologramCloud (https://hologram.io)
HTTP_LAT = 31.7796837
HTTP_LON = -106.4
CONTENT_LENGTH = 32
REMOTE_ADDR = 23.253.159.55
DOCUMENT_ROOT = /var/www/html
REQUEST_SCHEME = http
CONTEXT_PREFIX = 
CONTEXT_DOCUMENT_ROOT = /var/www/html
REMOTE_PORT = 48676
GATEWAY_INTERFACE = CGI/1.1
REQUEST_METHOD = POST
QUERY_STRING = 
REQUEST_URI = /post.php
PHP_SELF = /post.php
REQUEST_TIME_FLOAT = 1508392863.321
REQUEST_TIME = 1508392863

No Post Params.
Empty post body.

Upload contains PUT data:
&lat=31.7796837&lon=-106.4787569

So the data coming from hologram is only included as PUT data not in actual POST parameters.

How can I fix that?

That’s really weird considering we don’t support PUTs right now. I’ll investigate further and get back to you

I dug into this some more and it looks like it is because of the Content-Type header.
When I set the Content-Type correctly based on the payload then everything works:

Time: Thu, 19 Oct 17 20:29:00 +0000
Source ip: 172.99.68.109

Headers (Some may be inserted by server)
HTTP_HOST = posttestserver.com
HTTP_CONNECTION = keep-alive
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT = */*
HTTP_USER_AGENT = HologramCloud (https://hologram.io)
CONTENT_TYPE = application/x-www-form-urlencoded
CONTENT_LENGTH = 22
REMOTE_ADDR = 172.99.68.109
DOCUMENT_ROOT = /var/www/html
REQUEST_SCHEME = http
CONTEXT_PREFIX = 
CONTEXT_DOCUMENT_ROOT = /var/www/html
REMOTE_PORT = 35999
GATEWAY_INTERFACE = CGI/1.1
REQUEST_METHOD = POST
QUERY_STRING = status_code=400
REQUEST_URI = /post.php?status_code=400
PHP_SELF = /post.php
REQUEST_TIME_FLOAT = 1508444940.84
REQUEST_TIME = 1508444940

Post Params:
key: 'test1' value: 'asdf'
key: 'test2' value: '1234'
Empty post body.

Upload contains PUT data:
&test1=asdf&test2=1234

I can confirm that that works! Thanks for the help!

BTW, how did you know that Content-Type in the dashboard would resolve to CONTENT_TYPE in the request that was sent?

It doesn’t really. We send it exactly as shown. I think that guy is just pulling all the variables right out of what PHP gives you and it normalizes things into that format. RequestBin is a more accurate representation of what gets sent.
Content-Type is the official HTTP header.

1 Like