jsonhttparduinoxively

Xively PUT request error HTTP 411, Content-Length Required?


So I've got an arduino uno with a CC3000 shield attached and I want to push data to my Xively account: https://xively.com/develop/yS4XfViIIEEkB94MJ4zs However I get this error when I connect:

Connected!
Request DHCP
api.xively.com -> 64.94.18.120
Data Lengthz

PUT /v2/feeds/97346308.json HTTP/1.1
Host: api.xively.com
X-ApiKey:mykey
Content-Length: z
Connection: close


{"version":"1.0.0","datastreams" : [ {"id" : "Longitude","current_value" : ""},{"id" : "Latitude","current_value" : ""}]}
Connected to Xively server.
--------------------------------------
HTTP/1.1 411 Length Required
Date: Fri, 08 Aug 2014 13:19:33 GMT
Content-Type: text/html
Content-Length: 181
Connection: close

<html>
<head><title>411 Length Required</title></head>
<body bgcolor="white">
<center><h1>411 Length Required</h1></center>
<hr><center>nginx/1.1.19</center>
</body>
</html>

I understand that error 411 is a call for content length but I've alread declared this in my header and I still get this error. Any help would be greatly appreciated :)


Solution

  • The Content-Length value must be a sequence of digits. What you sent is a letter, so the server complained that it didn't get your header in the correct format.

    Instead of:

    Content-Length: z
    

    Use:

    Content-Length: 0
    

    If you are actually including data in the body of your request, the length should be the number of octets in the encoded body.