html post method question

Describe your system and processes, and post your config file.
Post Reply
lostbadgers
Posts: 2
Joined: Fri Aug 03, 2012 1:01 pm
Bot?: No

html post method question

Post by lostbadgers »

I will be the first to admit that I can be dense sometimes, but shouldn't this simple html code update ulstate.dat?

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<title>Sample of HTML Form Submission to BCS462</title>
<H1>Sample Data Submission</H1>
<P>Clicking Submit Query will write predefined data string to the BCS462
<FORM METHOD="POST" ACTION="http://192.168.50.253/ulstate.dat?p=0&s ... ,0,0,0,0,0,">
<P><INPUT TYPE=SUBMIT> <INPUT TYPE=RESET>
</FORM>

I certainly am missing something since I get a connection timeout error but I am not sure what it is. maybe I am oversimplifying the data submission?

Thanks for any help. I am not a developer per se but I do like tinkering.
User avatar
bbrally
Posts: 210
Joined: Sat Mar 27, 2010 3:59 am
Bot?: No
Location: Vancouver, BC
Contact:

Re: html post method question

Post by bbrally »

I think your problem may be due to same origin policy.

Reference this forum post: http://www.embeddedcontrolconcepts.com/ ... f=11&t=732

Perhaps if enough people request a CORS header addition it could be added on a future update.

To get around this problem I wrote my custom UI in another language than HTML/javascript.
lostbadgers
Posts: 2
Joined: Fri Aug 03, 2012 1:01 pm
Bot?: No

Re: html post method question

Post by lostbadgers »

Thanks, bbrally, I will dig into that post. I have a suspicion I will be writing my interface using another program myself - maybe HTML and PERL since there are some PERL routines already out there. I have XAMPP Apache server on my laptop so maybe I will run everything off that. My ultimate goal is to parse the Beersmith XML recipe files to populate and run my system in real time but I am certainly far from that goal at this point.
hoofheartedbrewing
Posts: 4
Joined: Sat Jun 22, 2013 6:35 am
Bot?: No

Re: html post method question

Post by hoofheartedbrewing »

I'm a little late to the party. Posting to the device is allowed. I was able to get it working and will outline how I went about doing it.

If you use Chrome as a browser, there is an addon called POSTMAN that allows you to test RESTful APIs like this one. You can set custom headers, you can POST, etc.

Also, the native BCS webserver uses AJAX calls via JavaScript to control the device. This is great because you can use Chrome's Net tab to see the request that the device sends itself allowing you to deconstruct the format of the request.

Let's say authentication is enabled, the username is admin, and the password is YourPass.You would set a request header Authentication: Basic YWRtaW46WW91clBhc3M= to authenticate to the device. The string YWRtaW46WW91clBhc3M= is a base64 encoded version of admin:YourPass.

So the request URL on my device is http://192.168.1.77/ulstate.dat?p=0&s=0 and the string you post to it is in the format ?data&p=0&s=0&5616000,0,0,0,720,750,750,750,750,750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,. In this example I am updating the temperature setpoint of Process 0, State 0, Output 0 to 72°F.

I am attaching screenshots from POSTMAN that will hopefully give a visual representation of what I have described here.

Step 1: Enter URL, select POST, enter string in RAW format, and enter Basic Authentication.
Step 1: Enter URL, select POST, enter string in RAW format, and enter Basic Authentication.
Step 1: Enter URL, select POST, enter string in RAW format, and enter Basic Authentication.
1.JPG (87.27 KiB) Viewed 6005 times
Step 2: Click the Refresh headers button to add the base64 encoded authentication to the headers.
Step 2: Click the Refresh headers button to add the base64 encoded authentication to the headers.
Step 2: Click the Refresh headers button to add the base64 encoded authentication to the headers.
2.JPG (84 KiB) Viewed 6005 times
Step 3: Click the Send button.
Step 3: Click the Send button.
Step 3: Click the Send button.
3.JPG (90.75 KiB) Viewed 6005 times
Post Reply