• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Executing a URL without a browser opening

JCTalk

Member
Hi,

I'm trying to execute a URL (includes parameters) from Excel via VBA, without opening a browser. I do not want a response from the website, I simply want to execute the URL.
I've tried using "WinHttp.WinHttpRequest.5.1" to POST the URL, but it keeps failing on the .Send part with "The HTTP redirect request failed".

Here's what I've tried built up from various Google searches on the subject...

Code:
Set httpSend = CreateObject("WinHttp.WinHttpRequest.5.1")
websiteURL = "https://www.somewebsite.com/?&staticVariable=xxxx"
websiteArguments = "&anotherVariable=" & variable2

httpSend.Open "POST", websiteURL, False
httpSend.Send (websiteArguments)
websiteResponse = httpSend.ResponseText
Set httpSend = Nothing

Any thoughts on why this would fail at the .Send part? Is there another Object type that would be better suited to just executing a URL with no response required?

Many thanks.
 
Hi Marc

Thank you for your reply. I tried GET a little earlier, before I moved onto POST, it hung my spreadsheet and kept repeating the URL execution for some reason.

It's important that it only executes the URL once as the full URL when ran works as a command to create a new "item" on our system. When I used GET it created 85 new items in seconds lol. Luckily it is our test system. :)
 
So it's just a request misuse !

When you operate manually from a webbrowser,
see in its inner inspector tool which exact request is achieved
with its parameters, headers, …

Or you have the easy way to just pilot Internet Explorer instead …
 
Hi Marc,

Yes I think "misuse" on my part will almost definitely sum it up. :)

I did as you suggested and you are right, the URL executed in a browser is received as a GET request.

Given my original code suggestion... aside from substituting POST for GET, can you see any glaring error's that would cause the request to keep looping indefinitely?

Many thanks for your help, this is the first time I've ever made use of this feature.
 
Back
Top