Http request for an array

spidaman

Board Regular
Joined
Jul 26, 2015
Messages
116
Office Version
  1. 365
Platform
  1. Windows
I am struggling to make a http request for each item of an array in VBA. When I make the request for a single object there is no problem:

VBA Code:
Dim xml_obj As MSXML2.XMLHTTP60
Set xml_obj = New MSXML2.XMLHTTP60

xml_obj.Open bstrMethod:="GET", bstrURL:=url1
xml_obj.send

But when I try and use the request method for each item in an array I get the error: '-2147024809 (80070057)'.
I can't find anything useful online for the error code.
The code below is throwing the error.

VBA Code:
Dim url1(1 To 5) As String
Dim xml_obj As MSXML2.XMLHTTP60
Set xml_obj = New MSXML2.XMLHTTP60

For i = 1 To UBound(url1)
    xml_obj.Open bstrMethod:="GET", bstrURL:=url1(i) ' error thrown on this line
    xml_obj.send
Next i

I have tested the url1 string for each item in the array before the http request and these are valid strings for the request, so I believe the problem is my code for making the multiple requests.

I am unsure if I need to set an array for the xml_obj. Can anyone help please?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I see no data in the array. I guess you can do i=1 to 1 and see if the first element does what you want.

Set the 3rd input to False for ASYNC.
VBA Code:
'xml_obj.Open bstrMethod:="GET", bstrURL:=url1(i) ' error thrown on this line
xml_obj.Open "GET", url1(i), False
 
Upvote 0
I see no data in the array. I guess you can do i=1 to 1 and see if the first element does what you want.

Set the 3rd input to False for ASYNC.
VBA Code:
'xml_obj.Open bstrMethod:="GET", bstrURL:=url1(i) ' error thrown on this line
xml_obj.Open "GET", url1(i), False
Hi Kenneth, what does setting the third input to asynchronous do?
 
Upvote 0
I put it at False. We usually want one process to end before starting another. I guess you can try True to see if that is the better route.
of or requiring a form of computer control timing protocol in which a specific operation begins upon receipt of an indication (signal) that the preceding operation has been completed.
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,400
Members
448,893
Latest member
AtariBaby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top