Jump to content
Sign in to follow this  

Script runs on WinXP, not on Server 2008 (Unknown content-type)

Recommended Posts

I am trying to write a script to sent POST data to our Alpha Page provider so I can send a page in a SQL script.  I have written the script below which works perfectly on my Windows XP workstation.  When I try to run it on my server (Windows Server 2008 RS SP1) it doesn't work at all.  Here's my script:

If $CmdLine[0] < 2 Then
    MsgBox(0,"MISSING PARAMETERS","Must supply command parameters Pager Number and Message to send." & @CRLF & "Pager should NOT include dashes, and Message MUST be enclosed in quotes" & @CRLF & @CRLF & "Example:" & @CRLF & "AutoPage.exe 8885551234 ""This is a test message""",15)
    Exit ; No parameters, nothing to do!

$pager = $CmdLine[1] ; The first parameter - PAGER NUMBER
$msg = $CmdLine[2] ; The second parameter - MSG TO BE SENT
$msg = StringReplace($msg, " ", "+")

; The final POST data to be sent via HTTP
$sPD = 'pager_num=' & $pager & '&message=' & $msg

; Creating the object
$oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
$oHTTP.Open("POST", "http://www.propage.net/cgi-bin/propage/pager_test.pl", False)
$oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")

; Performing the Request

; Download the body response if any, and get the server status response code.
$oReceived = $oHTTP.ResponseText
$oStatusCode = $oHTTP.Status

; Saves the body response regardless of the Response code
$file = FileOpen("Received.html", 2) ; The value of 2 overwrites the file if it already exists
FileWrite($file, $oReceived)


The HTTP response from my WORKING workstation looks like this:

<title>Pager Service</title>
<body bgcolor="white" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<table width="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
<tr><td valign="top">
<br><font face="arial,helvetica,verdana" color="#1d0975">
  <a href="http://www.propage.net" target="window"><img src="http://www.propage.net/imgs/netbanner.gif" align="right" border="0"></a>

  Successfully sent to 888xxxxxxx <br>
  If this is the correct number or user-name for the intended subscriber, the message will normally be received within 10 to 15 seconds.<br><br>
  If there was an error and the message was not sent, please click the <b>BACK</B> button on the browser and try again.

    <TD valign="top"></td>
    <TD valign="top"></TD>

    <TD colspan="3"><font face="arial,helvetica,verdana" color="#1d0975">
<hr with="100%">

While the Response code from the server looks like this:

<title>cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded; Charset=UTF-8
<h1>cgi-lib.pl: Unknown Content-type: application/x-www-form-urlencoded; Charset=UTF-8

Does anyone have any suggestions on what could be happening here?

Edited by MuffinMan

Share this post

Link to post
Share on other sites

OK, I tried this on serveral different servers and it ran fine EXCEPT on Windows Server 2008 machines.  I did some research and found that there seems to be some sort of issue with WinHTTP on Server 2008.  I changed my object to:

$oHTTP = ObjCreate("MSXML2.XMLHTTP")

Which uses WinINet instead on WinHTTP.  My code now seems to be working on Server 2008 and the rest of the servers / workstations.  Still very interested if anyone else has anything to add, but bottom line is the code works now.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Create New...