Error at “attribute_write on a device”


#1

i am following the same example to turn the led light on.
I am posting to : “url”: “https://api.afero.io/v1/accounts/"+accountId+"/devices/"+deviceId+"/actions”,
“headers”:{
“Content-Type”: “application/json”,
“Accept”: “application/json”,
“Authorization”: "Bearer "+accessToken
},
“params”:
{
“type”: “attribute_write”,
“attrId”: 1024,
“data”: “0000”
}
,
“method”: “POST”
}

i am getting this :
“body”: "{‘timestamp’:1496063310350,‘status’:400,‘error’:‘Bad Request’,‘message’:‘Could not read JSON document: Unrecognized token ‘type’: was expecting ‘null’, ‘true’, ‘false’ or NaNn at [Source: java.io.PushbackInputStream@3b49943f; line: 1, column: 6]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token ‘type’: was expecting ‘null’, ‘true’, ‘false’ or NaNn at [Source: java.io.PushbackInputStream@3b49943f; line: 1, column: 6]’

taking into consideration that the mobile app is turning the led on and off successfully.
Please advice


#2

Hi Elie,

Hmm… I’m able to use this same API to POST an attribute write and it’s working fine for me. I copied and pasted your JSON body above and it worked fine. The error you’re getting is from the JSON parser on our end trying parse what it got in the body of your message. Your parameters look okay to me, do you mind posting a line or two of the code that actually POSTs that message to the API?

Specifically I am wondering if your code is sending that JSON as the body content of the POST message or not… that JSON goes in the body of the message and not as parameters.

Cheers,

Joe