We help IT Professionals succeed at work.
Get Started

Use MS Access VBA to create http post request

Rick Rudolph
Rick Rudolph asked
on
254 Views
Last Modified: 2019-12-11
I am trying to send http requests to the API provided by HelloSign.com........To test what I was doing, I used Git BASH, and the following command completed correctly (I have changed the key and some of the user / document information, but the syntax is exactly as I sent it):

curl -u "9Ca9C0972a4e1ae439Cee8e5d54CCa881031ba247e085807a847aa86Ca080d6a:" "https://api.hellosign.com/v3/signature_request/send" -F "title=rjr.docx" -F "subject=Rick's Test Document" -F "message=Please sign this contract" -F "signers[0][email_address]=rrudolph@test.com" -F "signers[0][name]=Rick Rudolph" -F "file[0]=@c:/docpath/rjr.docx" -F "test_mode=1"

I opened up a VBA module, and set a reference to the Microsoft XML 6.0 library. Then I tried the following:

Public Function TestAPI()

Dim StrAPI As String
Dim request As MSXML2.ServerXMLHTTP60
StrAPI = " -u '9Ca9C0972a4e1ae439Cee8e5d54CCa881031ba247e085807a847aa86Ca080d6a:' 'https://api.hellosign.com/v3/signature_request/send' -F 'title=rjr.docx' -F 'subject=Rick's Test Document' -F 'message=Please sign this contract' -F 'signers[0][email_address]=rrudolph@test.com' -F 'signers[0][name]=Rick Rudolph' -F 'file[0]=@c:/docpath/rjr.docx' -F 'test_mode=1'"
Set request = New ServerXMLHTTP60
request.Open "Post", StrAPI, False
request.send
Debug.Print request.StatusText

End Function

This code created an error at :  request.Open "Post", StrAPI, False

The error was:
runtime error '-2147012890 (80072ee6)
System error: -2147012890

The only change I made to the string that worked in Curl was to change the double quotes to single quotes inside the string.

Thanks in advance as this is a stumbling block in a new process we are trying to develop.
Comment
Watch Question
President
Commented:
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE