Pira.cz Technical Forum

Magic RDS 4 => Feature Requests => Topic started by: jcmarsalis on January 05, 2024, 08:58:37 pm

Title: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on January 05, 2024, 08:58:37 pm
Hi I am working with DTS Autostage to send our now playing data. The want it as a HTTP POST (not HTTP GET). Can I accomplish this in Magic RDS?
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: Jan on January 05, 2024, 10:44:47 pm
Before we implement direct solution, you can POST the text like as showed in following example:

Code: [Select]
saveto file:"d:\post.txt"
cmd "curl -k --data-urlencode varname@d:\post.txt https://server.com/input.php"

Enter such script into the Data Distribution box (Edit Connection - Connection Type: internal channel)

Modify the script:
varname is the variable name accepted by your webserver
d:\post.txt can be changed to any local file name in any existing path
https://server.com/input.php is the URL which accepts the POST request

The text coding is UTF-8 by default.
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on January 06, 2024, 03:55:37 pm
Thank you. I've implemented as you described. Will wait to see if they're getting information.
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: bstapley on February 02, 2024, 05:39:08 pm
If I edit the current connection, won't I "break" the current connection to my encoder?  Also, I don't see the Data Distribution box in my current connection.  Current connection is a Kind = RDS Encoder --> Model = Generic UECP.

Before we implement direct solution, you can POST the text like as showed in following example:

Code: [Select]
saveto file:"d:\post.txt"
cmd "curl -k --data-urlencode varname@d:\post.txt https://server.com/input.php"

Enter such script into the Data Distribution box (Edit Connection - Connection Type: internal channel)

Modify the script:
varname is the variable name accepted by your webserver
d:\post.txt can be changed to any local file name in any existing path
https://server.com/input.php is the URL which accepts the POST request

The text coding is UTF-8 by default.
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: Jan on February 02, 2024, 06:47:02 pm
The description above does not apply to your existing connection to the RDS encoder.

Add a new Connection, kind: Bridge, connection type: internal channel. This method is also decribed in the Help: ontheweb.pdf
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on June 27, 2024, 09:02:20 pm
Thank you. I've implemented as you described. Will wait to see if they're getting information.

Is there any reason RDS Magic would have trouble with executing a batch file?
Something like

cmd "C:\Users\jcm\Doucuments\send.bat"
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: Jan on June 27, 2024, 09:13:54 pm
cmd "C:\Users\jcm\Documents\send.bat"
in the Internal Channel

or

open "C:\Users\jcm\Documents\send.bat"
in the regular script.
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on June 27, 2024, 10:13:29 pm
Thanks!
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on July 08, 2024, 09:58:21 pm
I am not convinced the Internal Channel is executing my batch file on data change. My batch file contains a curl command that works fine when executed manually from the command prompt. I had to put the url for the curl command in double quotes for it to work, and RDS Magic wouldn't accept that directly in the Internal Channel, hence the reason for the batch file. I put the following at the end of my batch file to try to get some indication that the script is firing:

echo Logged time = %time% %date%> [full path]\sharklog.txt

but it is not updated unless I run the batch file manually from the command prompt. My instance of RDS Magic is set to Run as Administrator. Log file is not updated when I use the Execute Script tool either.
RDS Magic version 4.0.36 build 2022-01-27
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: admin on July 09, 2024, 07:09:58 am
Please use only the most recent version of the Magic RDS. I'm not able to give you any comment to a version which is more that 2 years old.
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: jcmarsalis on July 09, 2024, 11:46:06 pm
Updated all instances to current ver. Seems to be working now... sending and executing batch file. Thanks
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: broybal on November 09, 2026, 08:55:43 pm
Sorry if this is an old thread.

I'm attempting to also execute a batch file that I've written from an internal channel to deliver a JSON payload via HTTP Post to dts.

Here's my internal channel data distribution settings:
Quote
saveto file:"C:\Program Files (x86)\Magic RDS 4\DTS\wxxxpost.json"
cmd "C:\Program Files (x86)\Magic RDS 4\DTS\wxxxdts.bat"

The JSON file creation works flawlessly, and the batch file posts the JSON file correctly which I can verify when run manually through windows, but I cannot seem to get Magic RDS 4 to execute the batch file even though it's logged in recent events:
Quote
26-11-09 14:50:16; Executed cmd /C runcmd.bat C:\Program Files (x86)\Magic RDS 4\DTS\wxxxdts.bat

Anybody have any advice?
Title: Re: need to send via HTTP POST (not HTTP GET)
Post by: Jan on November 09, 2026, 09:48:36 pm
Thank you for the nice description of your case.

You didn't make any mistake. However, it won't work for you because the file path contains a space; this requires extra quotation marks, which must also be escaped. The correct line is as follows:

Code: [Select]
cmd """C:\Program Files (x86)\Magic RDS 4\DTS\wxxxdts.bat"""
I am fully aware that this is not very intuitive. Although it might seem that the program could add the quotation marks automatically, this is unfortunately not possible because there is no reliable way to determine where the file path ends and the command-line parameters begin. Any attempt to guess could break otherwise valid commands.

Therefore, if a file path contains spaces, it must be enclosed in double quotation marks. This applies to both the executable file and any file paths passed as parameters.

For example:

cmd """C:\Program Files\MyApp\program.exe"" ""C:\My Documents\data.txt"""

This ensures that commands are passed to Windows without modification, preserving full flexibility and compatibility with Windows command-line syntax.

I should also point out that, in Windows, folders located under Program Files are not intended for storing working files; in fact, doing so is often impossible due to a lack of the necessary permissions.