Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting "401 - Unathorized" using IntGetFile
#1
Hello,
I am relatively new to Quick Macros, but I have a quick question about using IntGetFile:

Currently, I am trying to call a webservice to get some information returned back to my project. If I hit the server directly via browser, a popup occurs with label "Windows Security" and I need to enter in my Username and Password to get authenticated. Now, I am trying to simulate this with QM using IntGetFile. When I do that though, I get a 401 - Unauthorized error returned back to the header. This is my code:

QM
Code:
Copy      Help
str getURL = "http://blah.org/service.asmx/getInformation"
IntGetFile getURL xmlStr 0 0 0 0 0 &responseHeaders

out "*********** xmlStr***********"
out xmlStr

out "*********** response headers***********"
out responseHeaders


xmlStr
Code:
Copy      Help
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
  <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
  <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
</fieldset></div>
</div>
</body>
</html>

responseHeaders
Code:
Copy      Help
HTTP/1.1 401 Unauthorized
Content-Type: text/html
Server: Microsoft-IIS/7.5
WWW-Authenticate: NTLM
WWW-Authenticate: Negotiate
X-Powered-By: ASP.NET
Date: Wed, 06 Apr 2016 13:58:32 GMT
Content-Length: 1293

Obviously I am getting bounced out because I didn't provide my username and password, so my question is, is there a way for me to pass in the credentials when I make this call via QM? Should I use IntGetFile, fiddle around with the parameters to pass in the credentials, etc.?

I hope this was clear, and thanks in advance! Big Grin
#2
I would try:

Call IntGetFile as it is.
If it returns an error:
- Show custom dialog with web browser control, with the same URL or with the password form URL.
- Manually enter password.
- Call IntGetFile again.

Next time the first IntGetFile call should succeed, until you restart QM (or your macro.exe process) or a timeout.

If don't want to enter password manually, can try to POST the password form data, but it is quite difficult and may not work. Maybe easier is to show the web browser dialog hidden and automate entering password with accessible object functions or HTML element functions or easier with function AutoPassword.

Instead of creating custom dialog you can try to download the file with HtmlDoc class functions. It creates a hidden web browser control (depends on options). Then automate entering password in the popup window.

To automate entering password, probably will need to do it in other thread, because your macro will wait until the dialog is closed. Use mac to create new thread.


Forum Jump:


Users browsing this thread: 1 Guest(s)