18

I have an API for my application which allows me to make cURL requests to it. I need to implement this into VBA so my desktop database can fire CURL requests to my web app.

curl -i --user [email protected]:password -X PUT -d "test=testing" https://mywebsite.com/api

How can i implement this in Access VBA? Can i use WinHttp.WinHttpRequest.5.1 ? Any examples? Thanks Adam,

1 Answer 1

30

Solved it now guys, works well. For other peoples convenience.

TargetURL = "https://www.mysite.co.uk/app/api/v1/test"
Set HTTPReq = CreateObject("WinHttp.WinHttpRequest.5.1")
HTTPReq.Option(4) = 13056 '
HTTPReq.Open "PUT", TargetURL, False
HTTPReq.SetCredentials "user", "password", 0
HTTPReq.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
HTTPReq.send ("test[status]=" & Forms!curl!Text0.Value & "&test2[status]=" & Text2.Value)
MsgBox (HTTPReq.responseText)
Sign up to request clarification or add additional context in comments.

4 Comments

What is the significance of Option(4)? The WinHttpRequest documentation doesn't specify.
I know it is 3 years ago, but I also wondered what this Option(4) is there fore and I found some useful information under this link johankanngard.net/2005/11/11/…
According to the WHR Option docs, the 4 is the enumeration value "WinHttpRequestOption_SslErrorIgnoreFlags". If you convert the 13056 to hex, you get 0x3300, which if you look further down to the SslErrorIgnoreFlags description, you can see that this ignores all the errors.
Thank u a lot. I used a Get method, so I didn't use parameters, only url, but it worked just fine. Thank you again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.