json - Url In Get 请求更新,但从 get 请求返回不更新
问题描述
我有一个获取请求,它调用使用 API 密钥获取 json 数据。当我在浏览器中测试 url 时,它可以很好地处理来自 api 密钥的所有更新数据。当我从 VBA 函数中的 API 密钥返回数据时,它仍然显示以前的数据。
url 更新,但是由于某种原因,保存从 url 调用的 json 数据的变量没有更新,因此仍然包含旧数据。
当我关闭 excel 工作表并重新打开它时,变量会更新为最新数据。我已经被困了一天半了,任何帮助将不胜感激。
这是相关代码:
Public Function getHTTP(ByVal url As String) As String
Dim xmlhttp As New MSXML2.XMLHTTP60
With xmlhttp
.Open "GET", url, False: .send
getHTTP = StrConv(.responseBody, vbUnicode)
End With
End Function
Function callingGetReq()
Dim stage1 As String
stage1 = "x"
callingGetReq = " "
Worksheets("Hub Api Data Sheet").Range("B4", "B2").Clear
Dim email As String
email = Worksheets("Dom. Inputs").Range("B28").Value
Dim url As String
Dim api_key As String
api_key = "?hapikey=#####################################"
Dim count As String
count = "&count=1"
Dim property As String
property = "&property=customer_number&property=salutation&property=firstname&property=lastname&property=email&property=zip&property=address&property=city&property=state&property=address_line_2&property=hs_searchable_calculated_phone_number"
Dim propertyMode As String
propertyMode = "&propertyMode=value_only"
Dim formSub As String
formSub = "&formSubmissionMode=newest"
Dim listMem As String
listMem = "&showListMemberships=true"
url = "https://api.hubapi.com/contacts/v1/contact/email/" + email + "/profile" + api_key + propertyMode + property + formSub + listMem
MsgBox
stage1 = getHTTP(url)
callingGetReq = stage1
Worksheets("Hub Api Data Sheet").Range("B4") = callingGetReq
Worksheets("Hub Api Data Sheet").Range("B2") = url
' ActiveCell = " " + callingGetReq + " "
End Function
在其他解决方案中,我试图清除变量,但这无济于事......
任何想法将不胜感激。
解决方案
推荐阅读
- spring - Spring Jpa findBy 方法来获取最佳结果
- javascript - 手机上的签名板。从光标沿 X 和 Y 轴绘制几厘米的距离
- elasticsearch - 请求字符串和数字字段时的 Elasticsearch java.lang.NumberFormatExcepion
- python - PyQt5点击按钮:Python已停止运行
- c# - 如何找出我的应用程序实际可用的 RAM 量?
- angular - 如何在具有 ngrx 实现的 Angular 应用程序中使用路由器状态
- ios - 子视图不滚动,但滚动条出现快速滚动
- excel - Excel VBA Range.Replace 对整个工作簿进行操作
- python - 如何将只有一个公共维度(批量大小)的两个 3D 张量传递给 dynamic_lstm?
- excel - VBA for Excel:与另一列重复项相比,计算唯一元素