Failing to send json message

Im trying to sync my imp with pushover service.
they have a detailed API how to use. I followed their guide and created token for an app i created, i have my user id also and i try to send a message.
the api can be followed here: http://pushover.net/api#messages
I tried various outputs, all fails with 400 bad request, i guess its because i dont succeed to create the data correctly.
i tried:
a = { token="TOKEN_ID" user="USER_ID" message="hellooo" } strout.set(a);
and my http request is set to the correct url, with POST, i tried both url-encoded and json encoded. didnt help.
i tried also to set strout to \"token\":\"TOKEN_ID\",\"user\":\"USER_ID\",\"message\":\"Hi\""
or token=.....&user=....&message=.....
it seems that nothing helps. I tried to connect a “show input” which shows { errors: 'JSON/XML parameter input ... but i cant see the rest of the message to debug it correctly.
in url-encoded i have a different message: { token: 'invalid', errors: ['applicatio... but again, i dont know the rest of it.
could someone suggest something i can do?

Just a guess, but they have disabled JSON and XML input parsing according to this note.

so it is not working for me because i send an already parsed json request?
do i need to send a not-parsed request for it to work? (is it possible?)

You need to send data as parameters, and URL encoded, as in their spec:

`POST /1/messages.json
Host: api.pushover.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 180

token=KzGDORePKggMaC0QOYAMyEEuzJnyUi&user=e9e1495ec75826de5983cd1abc8031&device=droid4&title=Backup+finished±+SQL1&message=Backup+of+database+%22example%22+finished+in+16+minutes.`

I failed to mention but It’s the first syntax I tried
I tried to send to my output port just the string X =“token=… &…” it failed as the others

no one knows how i create such POST method with this particular data?

If you post your complete code I can take a look at it. pastebin.com is great for posting code.

I tried many combinations, it all comes to this sort of code:
`local lcdstr = OutputPort(“lcd string”);

class httpin extends InputPort
{
name = "HTTP IN Text"
type = “number”

function set(value)
{
if (“n” in value) {
initVariables(value.n);
operateSwitch(); //Turns off/on switch, buttons whatever…
lcdstr.set(“token=MY_APP_ID&user=MY_USER_ID&message=Hi”);
}
}
}
imp.configure(“Serial RX”, [httpin], [lcdstr]);
`

thats a small version of my code, initVariables, operateSwitch are irrelevant for this case.
I guess that the string I send to the output port is being encoded into something else, so if I want my msg to contain the data as I send it (feild=…&field2=…) How do i send it to my output port?
in the http request node in my planner I set it to POST to url http://api.pushover.net/1/messages.json and i tried both JSON or urlencoded.

One thing shouldn’t your output port be declared as
local lcdstr = OutputPort(“lcd”, “string”);

Also can you see what’s being emitted by HTTPout?
I use http://requestb.in/ for this sort of thing

requestb.in seems as a good idea, thank you.
I tried using wireshark to see traffic of the imp, but couldnt see any.
I will try this one, it will help me a lot.

I see the issue clearly…
It changes it to this:
value=token%3DTOKEN_NUMBER%26user%3USER_ID%26message%3DHi&target=307439dc9f5b635e&channel=1
it adds value=, at start, and changes ‘&’ to %3D, and adds garbage at the end.
Thats with urlencoded, when i try json, it sends
{"value":{"token":"TOKEN_NUMBER","message":"helloooo","user":"USER_ID"},"target":"307439dc9f5b635e","channel":1}

is there any way to get rid of this stuff?

No, I’ve only used GET which does the same.
When Agents come you will be able for sure to do this.
But for now you will have to use a proxy/intermediate server forward to Pushover which is a great service.

Maybe its a little OT, but do you know of any free solution?
when agents will come, i will be able to read the status of my imp, so i wont need to push a notification

No free service I know off other might.

when agents will come, i will be able to read the status of my imp
Yep is my understanding but for me I still want and need push notifications.

Well, i didnt find any other alternatives other than pushover.
unless it will be possible to create the data itself with agent, so i dont see how it will work