Error: bad parameters to, headers, body)

i have been struggling to get this to work but I get the error in the title (see snippet below)

2014-01-23 20:45:38 UTC-8: [Agent] Got temp from agent 21.488
2014-01-23 20:45:38 UTC-8: [Agent] bad parameters to, headers, body)
2014-01-23 20:45:38 UTC-8: [Agent] at send_xively:13
2014-01-23 20:45:38 UTC-8: [Agent] from unknown:27

`function send_xively(body)
{ //take in csv value
local xively_url = “” + FEED_ID + “.csv”;
server.log("Got temp from agent " + body); //print body for testing
local headers = { “X-ApiKey”:API_KEY, “Content-Type”:“txt/xml”, “User-Agent”:“Xively-Imp-Lib/1.0” };
//local headers = { “X-ApiKey” : API_KEY};

local req =, headers, body);     //create request
local res = req.sendsync();         //send request
if(res.statuscode != 200) 
{ server.log("error sending message: "+res.body);


I presume its a very simple answer but for someone starting out I cannot figure. Tried searching no luck.
Cheers, T.

edit: wrapped code in < code > </ code > tags.

RESOLVED: My Content-Type seemed to have either been outdated or incorrect. I used application/json and that worked.

If you’re interested, we have some nice classes that wrap up Xively quite nicely - you can find them here:

Yes thank you; been using it actually; without these there was no way for me to get it right!