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 admin@admin.com: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,
add a comment
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)
- 3What is the significance of Option(4)? The WinHttpRequest documentation doesn't specify. – StockB Oct 16 '13 at 14:51
- 2I 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/… – rodedo Sep 27 '16 at 8:38
- 3According 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. – livefree75 Dec 19 '18 at 14:54
- 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 – Juan Joya Jun 12 at 4:26