Help on xmlHttpRequest in Office 365 not working (but working in

Occasional Visitor

I was able to use the below VBA in excel of Office 365. But since yesterday, the code suddenly not working, which i return 403 .Status for using xmlhttprequest to scrap from external website .

I then test the code, it work Fine in Office 2007 ....May I know how to debug this code in office 365

 

Dim xmlHttpRequest As New MSXML2.XMLHTTP60


With xmlHttpRequest
.Open "POST", "https://www.investing.com/instruments/HistoricalDataAjax", False
.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "X-Requested-With", "XMLHttpRequest"

.send "curr_id=1057391&smlID=25609848&st_date=01%2F01%2F2017&end_date=03%2F01%2F2019&interval_sec=Daily&sort_col=date&sort_ord=DESC&action=historical_data"

If .Status = 403 Then
msgbox "403 error"
else
if 'Status = 200 Then
msgbox "Do sth"
end if
end if

0 Replies