Send file to ewon via M2Web API

Hi,
it’s possible to send the config.txt file via M2Web API to update the tag list of all my eWon?

the scenario is lithe this:
i have hundred ewon with the same tag configuration (all tag whit logging feature); if tomorrow i want to add a tag to log something new, i need to update manually each ewon.
so i want to write some code to do this automatically.

regards

@iw3bti1

While you cannot upload a file, you can in fact create a new tag via the API.

Here is a post that addresses this:

fantastic!
so via script i can modify all the tag property like via configfile?
for example i can decide to activate the logging property remotely on demand and then switch off?

@iw3bti1

That is correct!

In the example above, I wrote some endpoints that live on the eWON directly to make it easier however lets say you don’t want to do that and just want to use an API call. To do your logging you could do:

The script below is how you could trigger logging directly on the eWON:

IF(Trigger@=1) THEN
    SETSYS TAG, "Load", "YourTagName"
    SETSYS TAG, "LogEnabled",1 //Enable logging
    SETSYS TAG, "SAVE"
    PRINT "Logging Enabled Successfully"
ELSE
    SETSYS TAG, "LOAD", "YourTagName"
    SETSYS TAG, "LogEnabled",0
    SETSYS TAG, "SAVE"
    PRINT "Logging Disabled Successfully"
ENDIF
END

Now lets convert this to an API call:

https://m2web.talk2m.com/t2mapi/get/yourewon/rcgi.bin/ExeScriptForm?Command1=SETSYS "TAG", "LOAD", "YourTag"&Command2=SETSYS "TAG","LogEnabled",1&Command4=SETSYS TAG, "SAVE"&command4=cfgsave&t2mdeveloperid=yourid&t2maccount=account&t2mpassword=password&t2mdeviceusername=adm&t2mdeviceusername=password

The above URL call is almost a carbon copy of the script, just M2Web API’ified.

Really when it comes to interfacing with the device and updating custom parameters, you can do anything via a posted script.

I’m not sure what kind of application you are working on but here is a link to a Node.js library I wrote that has script functionality built right in!

hi jordan,
i’m trying to enable/disable remotely the logging of a tag via a little sw in C# based on m2web library for .NET.

i send this :slight_smile:
https://m2web.talk2m.com/t2mapi/get/myewon/rcgi.bin/ExecScriptForm?Command1=SETSYS “TAG”, “LOAD”, “mytag”&Command2=SETSYS “TAG”,“LogEnabled”,1&Command4=SETSYS TAG, “SAVE”&command4=cfgsave&t2mdeviceusername=myewonuser&t2mdevicepassword=myewonpass&t2maccount=myaccount&t2musername=myusername&t2mpassword=mypw&t2mdeveloperid=mydevid

but i have a response like this:
“<meta charset=“ISO-8859-1”/>Document Error: Data follows\r\n\t\t

Access Error: Data follows

\r\n\t\twhen trying to obtain <b id=“p”>
\r\n\t \r\n\t

Form ExecScriptForm is not defined

\r\n\r\n"

@iw3bti1

Ah I see the issue, there was a typo in my previous script. The form is actually ExeScriptForm, I had errantly put Exec.

Can you update your query to be:

https://m2web.talk2m.com/t2mapi/get/myewon/rcgi.bin/ExeScriptForm?Command1=SETSYS “TAG”, “LOAD”, “mytag”&Command2=SETSYS “TAG”,“LogEnabled”,1&Command4=SETSYS TAG, “SAVE”&command4=cfgsave&t2mdeviceusername=myewonuser&t2mdevicepassword=myewonpass&t2maccount=myaccount&t2musername=myusername&t2mpassword=mypw&t2mdeveloperid=mydevid

thank you Jordan, now works perfectly!

i think the same error is in this post:

@iw3bti1

Good catch! I’ll fix the error over there as well.