VBA中的等效cURL? [英] Equivalent cURL in VBA?

查看:14
本文介绍了VBA中的等效cURL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有一个 API,它允许我向它发出 cURL 请求.我需要将其实现到 VBA 中,以便我的桌面数据库可以向我的网络应用发出 CURL 请求.

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

如何在 Access VBA 中实现这一点?我可以使用 WinHttp.WinHttpRequest.5.1 吗?有什么例子吗?谢谢亚当,

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

推荐答案

现在解决了伙计们,效果很好.为了其他人的方便.

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)

这篇关于VBA中的等效cURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆