Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

How to correctly adapt this to REST API

I have this chunk of code where I create the POST request in Arduino Galileo directly with Ethernet library:

client.println(“POST /clientresp HTTP/1.1”);
client.println(“User-Agent: Galileo/0.0.1”);
client.print("Content-Length: ");

int content_length = 276 + username.length() + api_key.length() + temperaturesY.length() + timesX.length();
client.print(",“type”:“scatter”,“mode”:“lines+markers”,“visible”:true}&kwargs={“filename”:“galileo_temperature”,“fileopt”:“overwrite”,“style”:{“type”:“line”},“layout”:{“title”:“Galileo CPU Temperature”},“world_readable”:true}");

but when I send it I got the error where all the parameters are missing like below. How to format this code?

{“url”: “”, “message”: “”, “warning”: “”, “filename”: “”, “error”: “Missing required POST parameters: platform un key origin args kwargs”}HTTP/1.1 408 REQUEST_TIMEOUT

… Initializing ethernet
… Done initializing ethernet
… Attempting to connect to plotly’s REST servers
… Connected to plotly’s REST servers
… Sending HTTP Post to plotly
POST /clientresp HTTP/1.1
User-Agent: Arduino/0.6.0
Content-Length: 331

version=2.3&origin=plot&platform=arduino&un=UR5MHY&key=1wgvjsuwrv&args=[{“y”: [], “x”: [], “type”: “scatter”, “stream”: {“token”: “8rlclnrpym”, “maxpoints”: 100}}, {“y”: [], “x”: [], “type”: “scatter”, “stream”: {“token”: “koir5ybfa1”, “maxpoints”: 100}}]&kwargs={“fileopt”: “overwrite”, “filename”: “Data”, “world_readable”: true}
… Sent message, waiting for plotly’s response…
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 21 Dec 2015 21:43:07 GMT
Server: nginx/1.4.6 (Ubuntu)
Set-Cookie: csrftoken=pjacYJ16vmUazX56uoKjiYy8uO16EV3X; expires=Wed, 21-Dec-2016 21:43:07 GMT; Max-Age=31622400; Path=/; secure
Set-Cookie: anoncsrf=k5U0N4Qr0dvWPqIqRzd7DvUlICQNKMtF; expires=Tue, 22-Dec-2015 21:43:07 GMT; httponly; Max-Age=86400; Path=/
Vary: Accept-Encoding
Vary: Cookie
X-Frame-Options: SAMEORIGIN
Content-Length: 138
Connection: keep-alive

{“url”: “”, “message”: “”, “warning”: “”, “filename”: “”, “error”: “Missing required POST parameters: platform un key origin args kwargs”}HTTP/1.1 400 BAD_REQUEST
Content-Length: 0
Connection: Close

… Error initializing stream, aborting. Try again or get in touch with Chris at

I have the same problem…

This error can occur when the content length value send ahead of the data packet is less than the actual data length, so the API costs the data short, chopping off the end of the arguments.

Copy the data output into a file using vi and then check the length; I get 332 for your data not 331. It could be removing the final argument terminating bracket?

The opposite can also occur; send too large a number and the http request will hang and then timeout.