Passing event data to POST request in custom template

Hi , in the particle.io events tab , I do see the event and the data sent by the device. Please how do put this data into “subject” in the below custom template POST request ?

“event”: “mm_EVENT_PREFIX”,
“deviceID”: “1f002b001747353236343033”,
“url”: “https://api.mn.net/v3/chiefcentral.com/messages”,
“requestType”: “POST”,
“noDefaults”: true,
“rejectUnauthorized”: true,
“responseTemplate”: “”,
“form”: {
“to”: “max.may@hec.ca”,
“from”: “Chief Central noreply@chiefcentral.com”,
“subject”: “1234 Ninth Street, 416-555-1212”,
“text”: “1234 Ninth Street, 416-555-1212”
},
“auth”: {
“username”: “api”,
“password”: “key-7a36z3hhqwg515cmrb-xnwa5gjwsn-r2”
}

@mmai, I don’t think you received any responses yet due to the vagueness of the question. Please elaborate on what you are trying to do. Are you making a POST request from a Particle device? Which one (Photon, Electron, etc.) Are you using a library to make the POST request such as the HTTPClient library? Are you using webhooks to get/send data? Your sample JSON above isn’t properly formatted with a preceding and ending { } or [ ]. Is the data JSON? Is this JSON-looking data to be included in the body of the POST or in POST parameters?

2 Likes

thanks ninjatil, this screenshot shows the event published by my Photon, the data is “eureka”.

this other screenshot, scroll to bottom click edit . Then you will see the custom template link.How do I transmit data from Photon (“eureka”) to mm.net server , in any field of the form ? My call to mm.net works perfect with static data, as is.

You need to substitute your subject value with {{{PARTICLE_EVENT_VALUE}}}
If you looked at the default field definition for Webhook forms (before switching to custom) you’d have seen how it’s done.

BTW, that _EVENT_PREFIX bit of your event name seems to be redundant. Since the value is and event prefix by definition, it needn’t be called that way :wink:

2 Likes

thank you so much scruffr ! I will do that. If I become rich one day , I will send you a big check.

BTW, that _EVENT_PREFIX bit of my event name is voluntary put there to tell me what it is I am dealing with, as you say an “event prefix”. It’s learning process tag I put there, pretty wise , no ?

Cheers to you ! I was in programming like you in my first career. My first career was real-time systems C language programmer , from tracking systems to video games. Basically, I am a Jedi with the C language. Ask me anything. …i just read your profile: vic-20 6502’s. Remember Compuserve dial-up text adventure game "GO NORTH, PICK THIS, ETC. " ?

1 Like