PDA

View Full Version : Sending data to Extranet



lribeiro
10-10-2007, 04:04 AM
Hello. I'm trying to create an Access VBA script to POST data on an Extranet.
This Extranet is owned by one of my company suppliers. Manually I can logon
on a secure web site (https://extranet.suplier.pt/), and then point to an
https://extranet.suplier.pt/postdata.html and insert an username and password
(the same used for logon) and a text box with the data I want to post and
submit it to an https://extranet.suplier.pt/postdata.asp.
The extranet owner tells me that I can connect directly the extranet with my
application using https://extranet.suplier.pt/postdata.asp suplying username,
password and the data using POST method. When I do it programatically i get
"A connection with the server could not be established" error message. Can
anyone help me on this? The code i'm using is the following:

Sub httpPost()

Dim HttpReq As WinHttpRequest
Dim strFileName As String
Dim strFileText As String
Dim intFileNo As Integer

Set HttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

strFileName = "FileWithData.xml"
intFileNo = FreeFile()
Open strFileName For Input As #intFileNo
strFileText = Input(LOF(intFileNo), intFileNo)
Close #intFileNo

sURL = "https://extranet.suplier.pt/postdata.asp"
UserName = "uid"
Password = "pwd"

HttpReq.SetClientCertificate ("LOCAL_MACHINE\Personal\MyCertificate")

HttpReq.Open "POST", sURL, False
HttpReq.SetRequestHeader "content-type", "application/x-www-form-
urlencoded"

HttpReq.SetCredentials UserName, Password,
HTTPREQUEST_SETCREDENTIALS_FOR_SERVER

HttpReq.Send strFileText
Status = HttpReq.Status

MsgBox HttpReq.ResponseText

End Sub