Jump to content

Code examples for Networking resources & Quesiton on Web


strahan001

Recommended Posts

Can anyone throw a code sample for HTTP GET and POST on the forum? I have read through several areas and the WIKI with no luck, perhaps I am blind. I also googled the syntax and was left scratching my head. I was able to read an html file once but now can't repeat it. So I am stumped. Also, the webserver part of the ISY 99, does that allow me to connect to an actual webserver, via FTP to post a file? Perhaps I am doing this the wrong way.. I would like to post something to my web page and am just having a hard time.

 

Thank you

Sean

Link to comment
  • 5 months later...

What is it that you are trying to accomplish? It sounds like you have two different questions:

 

1. Using HTTP GET and POST in the network module

2. Getting content onto your ISY's web server

 

I'll address #2 first, as that's the simplest. As far as I know, the ISY web folders are only accessible via the Administrative Console. There is no FTP server to speak of.

 

As for #1, forgive me if I'm telling you something that you already know. Here goes...

 

The network module is capable of sending requests only. Although you can retrieve the contents of a URL, you can't do anything with it. I presume that any data retrieved is immediately discarded.

 

I think that the main idea behind the module is to send requests to network enabled devices that can respond to simple HTTP commands. Normally, this data is communicated by hitting a certain URL and optionally sending a script parameters to let it know what you want it to do.

 

You send the parameters via the URL with an HTTP GET or using name value pairs encoded into your request with an HTTP POST. The former looks like this:

 

http://somedeviceorserver/somescript.cgi?arg1=value1&arg2=value2

 

The arguments are passed in the URL itself and are found after the question mark. They are highlighted in boldfaced type above.

 

HTTP POST requests are usually sent by a form on an HTML web page. This form has a submit button that then URL encodes the contents of the form into a request that is then sent to the target via an HTTP POST. The target of the POST then parses out the parameters and decides what to do with them.

 

Since we don't have a form to send the HTTP POST because we're sending it via the ISY, you need to put your URL encoded key value pairs into the body of the request. These values will be in the same format as the HTTP GET. To send the same arguments as are used by the HTTP GET example above, you would put the following into the request body:

 

arg1=value1&arg2=value2

 

This describes URL encoded text (corresponding to the MIME type "application/x-www-form-urlencoded"). When sending multiple parameters in the body of the request, you must use "Raw Text" mode for the network resource so the ampersands ("&") used to separate your parameters aren't encoded. In some cases, you might have to try using Binary or C-Escaped modes if that's what your device expects.

 

Lastly, I mentioned "URL encoded" more than once. If you are using Raw Text mode, you probably need to encode your parameter values yourself so that you don't send junk data through or accidentally send special characters that mean something other than you intend. There are a number of tools on the 'net that can help you with that. Google "URL encoder" and you'll find something right away.

 

Hope that helps!

Link to comment
  • 2 years later...

I understand the ISY network module is only capable of invoking commands via HTTP. Is it possible to have the ISY (via network module) send a command to a FTP sight (like www.drivehq) for it to start a download (send) a specific file to a UPnP storage device on my local LAN? The ISY would not be storing any files, just initiating the commands to transfer the file from a cloud location to a local storage location. Or is there any other method to accomplish this?

Link to comment

Hi dano-

 

I'm not sure but IFTTT (If This Then That) may be capable of doing what you want. You could trigger an IFTTT rule from the ISY and let it do the rest. See IFTTT.com

 

Hope this helps.

 

-Xathros

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...