[AccessD] A2003: POST a set of params to a Web Resource
Darren - Active Billing
darren at activebilling.com.au
Fri Jul 12 12:57:17 CDT 2019
Stuart,
Thank you so much for replying. Sadly... no joy.
Also - realise I have no clue what I am doing here. So I may have stuffed something.
I get an error on the line "myXMLHTTP.send strPostData"
Error = "Run-time error '-2146697211 (800c0005)': "The System Cannot Locate the resource specified"
All I have done since getting you cool code below is, reference MSXML6 and Place my URL in the line you had at:
myXMLHTTP.Open "POST", "http://www.example.com/addtask.php", False
with
myXMLHTTP.Open "POST", "https://hooks.workast.app/Do7DOEFPZDzAS20cvtt6E", False
Do you have any suggestions?
Many thanks in advance.
Darren.
---------------------------------------------------------------------------
On 12/7/19, 12:56 pm, "AccessD on behalf of Stuart McLachlan" <accessd-bounces at databaseadvisors.com on behalf of stuart at lexacorp.com.pg> wrote:
---- Code HTTP POST-------------
Option Compare Database
Option Explicit
Function GetDBDump()
'Requires a reference to Microsoft XML 2.0 or greater
'I've use Microsoft XML 6.0 in Office 10.
Dim myXMLHTTP As XMLHTTP60
Set myXMLHTTP = New XMLHTTP60
Dim strResult As String
Dim strPostData as String
strPostData = URLEncode("text=This is theTask Name for Task No: 4&description=This is
the Description for Task No: 4&dueDate:'2019-10-07'")
myXMLHTTP.Open "POST", _
"http://www.example.com/addtask.php", False
myXMLHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows
NT 5.0)"
myXMLHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
myXMLHTTP.send strPostData
strResult = myXMLHTTP.responsetext
debug.print strResult
Set myXMLHTTP = Nothing
End Function
--------------END HTTP POST -------------------------------------
-------------URL ENCODE/DECODE ---------------------------------
Public Function URLEncode(StringToEncode As String, Optional _
UsePlusRatherThanHexForSpace As Boolean = False) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToEncode)
Select Case Asc(Mid(StringToEncode, CurChr, 1))
Case 48 To 57, 65 To 90, 97 To 122
TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
Case 32
If UsePlusRatherThanHexForSpace = True Then
TempAns = TempAns & "+"
Else
TempAns = TempAns & "%" & Hex(32)
End If
Case Else
TempAns = TempAns & "%" & _
Format(Hex(Asc(Mid(StringToEncode, _
CurChr, 1))), "00")
End Select
CurChr = CurChr + 1
Loop
URLEncode = TempAns
End Function
Public Function URLDecode(StringToDecode As String) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToDecode)
Select Case Mid(StringToDecode, CurChr, 1)
Case "+"
TempAns = TempAns & " "
Case "%"
TempAns = TempAns & Chr(Val("&h" & _
Mid(StringToDecode, CurChr + 1, 2)))
CurChr = CurChr + 2
Case Else
TempAns = TempAns & Mid(StringToDecode, CurChr, 1)
End Select
CurChr = CurChr + 1
Loop
URLDecode = TempAns
End Function
More information about the AccessD
mailing list