You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to retrieve data via a URL I receive a message: The data required for this operation is not yet available (error -2147483638 (8000000a).
This only happens when I run the macro for the first time.
When I click debug and run the macro again, it does get data from the URL cleanly.
It seems that the data is not yet available so he cannot retrieve it. I've already tried making the code wait for 10 seconds or 1 minute, but that doesn't solve the problem.
Any idea?
With http
.Open "GET", "https://api.rentman.net/projectequipment?limit=5&offset=0&sort=-modified, false"
.setRequestHeader "Content-type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Bearer " & authKey
.send
End With
Application.Wait (Now + TimeValue("0:00:01"))
Set JSON = ParseJson(http.responseText)
i = 2
For Each Item In JSON("data")
sht.Cells(i, 1).Value = Item("id")
sht.Cells(i, 2).Value = Item("modified")
sht.Cells(i, 5).Value = Item("equipment_group")
i = i + 1
Next
(text translated via Google translate)
The text was updated successfully, but these errors were encountered:
Your issue is not a VBA-JSON issue, it has to do with the fact you are calling the Http open method asynchronously. The wait time probably is not long enough however, you should be calling ParseJson in the callback routine rather than the way it is coded. Alternately, your code is basically synchronous, so just add false after the url in the Http open call and the call will be synchronous.
But wait you are saying, I have False after the Url!? Well no, that comma false is inside the quotes for the Url, thus the async parameter is True by default.
Wow, thanks for your quick response. It works and I'm very happy with that, thnxs!
There is just another problem now. When I run the macro for the 2nd time, it doesn't refresh the data.
I probably need to build somewhere that it has to wait for the responsetext?
Hello,
When I try to retrieve data via a URL I receive a message: The data required for this operation is not yet available (error -2147483638 (8000000a).
This only happens when I run the macro for the first time.
When I click debug and run the macro again, it does get data from the URL cleanly.
It seems that the data is not yet available so he cannot retrieve it. I've already tried making the code wait for 10 seconds or 1 minute, but that doesn't solve the problem.
Any idea?
(text translated via Google translate)
The text was updated successfully, but these errors were encountered: