arduinogprsxively

xively status:400 with arduino and sim900 gprs shield


Im using a cheap Sim900 GPRS shield with arduino and hopefully xively. I'm able to connect to xively with tcp but when i send in the data i get this response "status":400,"body":"Syntax Error: parse error: ". I'm using the sample from http://www.seeedstudio.com/wiki/GPRS_Shield_V1.0#SoftwareSerial_library_Notes and I've tried some modifications without any luck. I don't find documentation on how this string should look like.

My serial string looks like this: {"method": "put","resource": "/feeds/feednumber-removed/","params": {},"headers": {"X-PachubeApiKey":"device key removed"},"body": {"version": "1.0.0","datastreams": {"id": "Sensor1","current_value": "1031"}]},"token": "123"}

Can someone please help me on this subject?


Solution

  • Looks like your JSON may be missing some brackets. You also have some arguments that you dont need. Try something like this instead:

    {
        "method": "put",
        "resource": "/feeds/FEED_ID_HERE",
        "params": {},
        "headers": {"X-ApiKey":"API_KEY_HERE"},
        "body":  {
            "version" : "1.0.0",
            "datastreams": [
                {
                    "id": "Sensor1",
                    "current_value": "1031"
                }
            ]
        }
    }
    

    I have tried to make the bracketing as verbose and aligned as possible so you can see where the brackets need to be in order to conform to the Xively JSON format, and just correct JSON in general. I also updated the header name which has changed since the Pachube days.