Note that there are some explanatory texts on larger screens.

plurals
  1. POPost data with https does not get processed at Server side
    primarykey
    data
    text
    <p>I am having a VBScript which gets invoked from a 3rd party application, the script gets the data from the 3rd party application and opens the URL in an IE browser by passing the data in POST format. The script works fine when I use http as the protocol but the moment I use https, the server side code (request.getParameter("param1")) complains that it is not able to find the parameter in the request object. The script is called by passing the URL and the data. e.g. run.vbs <a href="https://xyz.com?param1=1234" rel="nofollow">https://xyz.com?param1=1234</a>. Following is the vbscript for your kind perusal. Can you please let me know what I am missing when I am using https as the protocol. Any help is highly appreciated. Many thanks.</p> <pre><code>If WScript.Arguments.Count = 1 Then uri = WScript.Arguments.Item(0) 'WScript.Echo "Arguments " &amp; uri Set WshNetwork = WScript.CreateObject("WScript.Network") 'WScript.Echo "Current User Name: " &amp; WshNetwork.UserName filename="C:\Documents and Settings\"+WshNetwork.UserName+"\Application Data\XYZ\Profiles\default\Settings.xml" 'WScript.Echo "Current User fileName: " &amp; filename Set xmlDoc = CreateObject("Microsoft.XMLDOM") xmlDoc.Async = "False" xmlDoc.Load(filename) strQuery = "Agent" Set colItem = xmlDoc.getElementsByTagname(strQuery) For Each objItem in colItem Agentid = objItem.getAttribute("Login") 'MsgBox "AgentId = " + AgentID Next 'uri = uri+"^&amp;agentid="+Agentid uri = uri+"&amp;agentid="+Agentid pos = InStr(uri,"?") extracteduri = Mid(uri,1,pos-1) params = Mid(uri, pos+1) postdata = Str2Bytes(params,"us-ascii") header = "Content-Type: application/x-www-form-urlencoded" Set IE = CreateObject("InternetExplorer.Application") 'IE.Navigate "about:blank" 'IE.AddressBar = True 'IE.ToolBar = True 'IE.StatusBar = True IE.Visible = True 'WScript.Sleep 2000 Set shl = WScript.CreateObject("WScript.Shell") shl.SendKeys "% X" IE.Navigate extracteduri, Nothing, Nothing, postdata, header Wscript.Quit Else Wscript.Echo "Usage: RunURL.vbs &lt;URL to invoke&gt;" Wscript.Quit End If Function Str2Bytes(Text, CharSet) Const adTypeText = 2 Const adTypeBinary = 1 'Create Stream object Dim BinaryStream 'As New Stream Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To save text/string data. BinaryStream.Type = adTypeText 'Specify charset For the source text (unicode) data. If Len(CharSet) &gt; 0 Then BinaryStream.CharSet = CharSet Else BinaryStream.CharSet = "us-ascii" End If 'Open the stream And write text/string data To the object BinaryStream.Open BinaryStream.WriteText Text 'Change stream type To binary BinaryStream.Position = 0 BinaryStream.Type = adTypeBinary 'Ignore first two bytes - sign of BinaryStream.Position = 0 'Open the stream And get binary data from the object Str2Bytes = BinaryStream.Read End Function </code></pre> <p>I am now using the below function to get the response from the server using https as the protocol and POST as the format but still the server is not able to see the parameter</p> <pre><code>Set req = CreateObject("MSXML2.ServerXMLHTTP") 'Set the below option to get rid of the "Certificate authority is invalid or 'incorrect, error code - 80072F0D" error req.setOption 2, 13056 req.open "POST", extracteduri, False req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" encodedParams = Escape(params) WScript.Echo "encodedParams: " &amp; encodedParams req.send encodedParams WScript.Echo "req.responseText: " &amp; req.responseText </code></pre> <p>Below are the encoded parameters uui%3DU1%3D123456%26agentid%3D123456</p> <p>The server still complains that the parameter is missing from the request object.</p> <p>I am using the same script (XMLHTTP request) but I am encrypting the parameters using the Str2Bytes function (declared above)</p> <pre><code>Set req = CreateObject("MSXML2.ServerXMLHTTP") req.setOption 2, 13056 req.open "POST", extracteduri, False req.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" req.send postdata WScript.Echo "req.responseText: " &amp; req.responseText </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload