HTTP Post Issue
sedmonds
Posts: 3
I am using the NI-3000 to connect to a Andover Controls Netcontroller with a built in webserver. I can connect and use the HTTP Get command to pull in the information from a page. The webserver has Post capabilities as well which allow you to change information in the Netcontroller. This works fine when done from Internet Explorer but from the NI-3000, it doesnt work.
Here is the post command from my code:
SEND_STRING dvIP_CLIENT,"'POST /pe/selfclose HTTP/1.1 ',13,10,'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, */*',13,10,'Accept-Language: en-us',13,10,'Content-Type: application/x-www-form-urlencoded',13,10,'Accept-Encoding: gzip, deflate',13,10,'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.3705)',13,10,'Content-Length: 12',13,10,'teststring=1',13,10,13,10"
I used Ethereal to capture the packet from the Internet Explorer machine and basically copied that Post command into Netlinx Studio.
Any ideas would be greatly appreciated.
Here is the post command from my code:
SEND_STRING dvIP_CLIENT,"'POST /pe/selfclose HTTP/1.1 ',13,10,'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, */*',13,10,'Accept-Language: en-us',13,10,'Content-Type: application/x-www-form-urlencoded',13,10,'Accept-Encoding: gzip, deflate',13,10,'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.3705)',13,10,'Content-Length: 12',13,10,'teststring=1',13,10,13,10"
I used Ethereal to capture the packet from the Internet Explorer machine and basically copied that Post command into Netlinx Studio.
Any ideas would be greatly appreciated.
0
Comments
SEND_STRING dvIP_CLIENT,"
'POST /pe/selfclose HTTP/1.1',13,10,
'Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, */*',13,10,
'Accept-Language: en-us',13,10,
'Content-Type: application/x-www-form-urlencoded',13,10,
'Accept-Encoding: gzip, deflate',13,10,
'User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.3705)',13,10,
'Host: 10.10.10.110',13,10,
'Content-Length: 12',13,10,
'Connection: Keep-Alive',13,10,
'Cache-Control: no-cache',13,10,13,10,
'teststring=1'"
Actually, the end of the POST body is indicated by the Content-Length header. Make sure that always changes to match the length of the body. You may have already done this, but I usually stick most of this in a function so I can just call POST('teststring=1') to construct the complete, including correct Content-Length header.
Jeremy
You may be able to shrink the amount of header data you need to send with your post message. Keep in mind that you are informing the web server what YOUR capablities are with regards to HTTP. I surely doubt you are working with the same capablities as IE or Firefox.
I've actually found that you do need to send all that chatter. Otherwise, depending upon the server, you get a 'you're browser is not worthy' message back.
These forums are a great help to guys like me just starting out with more advanced programming.
Thanks again.