HTTP request within a company that uses proxy

Asked

Viewed 125 times

4

I’m sorry if that question is repeated. I always try to get the answer before asking here, and this time I didn’t (I suddenly didn’t use the right keywords, perhaps for lack of knowledge, but whatever).

CONTEXT

I work in a company where I have restricted access to the internet. To access some websites, proxy is used.

In this company, from time to time I create small software to automate some demands. And for some of these demands, you need to access specific websites.

I use a lot of VBA to do this, since those who take advantage of these ask for a report of what was done, and making the software in Excel is very convenient.

For these softwares that access websites, I usually used VBA to control Internet Explorer, so that it reproduces the necessary actions. I never liked to do this, since some sites carried content without making the browser show that it was busy.

Recently I have been studying the Winhttp library, where I can make requests directly to the site I want and I get the HTML of the page, and found MUCH better than using Internet Explorer.

I already made 2 programs that worked perfectly. The first accessed a site available only on the company’s intranet. The second accessed an external site, and had to make explicit the Proxy to the Winhttp object. Thus, it worked normal.

PROBLEM

The third program is being problematic. It has to access an external website too, but even with proxy I do not get the HTML page. Request returns error 407 (proxy authentication required).

As in the second program that was made, no such authentication was requested?

I tried using the command .SetCredentials with my user and password, but nothing happens.

I remember that the answer has the headers: "Proxy-Authenticate": "Negotiate" "Proxy-Authenticate": "Kerberos" "Proxy-Authenticate": "NTLM"

I also tried to make the same request from outside the company (home), and received the html page normally, with the status 200.

How to make the program work within the company?

1 answer

1

With Teste
.Open "POST", "URL", False
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:70.0) Gecko/20100101 Firefox/70.0"

.setProxy 2, "PROXYAUTENTICACAO:8080" 'colocar o proxy
.setProxyCredentials "SUACREDENCIAL", "SUASENHA" 

End With

Browser other questions tagged

You are not signed in. Login or sign up in order to post.