Web Request node - unauthorized access [solved]

Hi,

I have a sharepoint. It has a web address. It needs an username and password though. I’ve tried to access the site from dynamo by using “Web Request” node and this is what i’ve got:

I couldn’t find any solution so I decided to start a new topic. Do you have any ideas?
This is how the authorization process looks like in the web browser:
image

SOLUTION FOUND!

I think you will need some Python for this and even then it may not work right depending on the security method used.

https://stackoverflow.com/questions/23416599/how-do-i-scrape-an-https-page

May be better off manually downloading the data you need locally, depending on the contents, intended use, and frequency of data pull.

Post edited, this is all I know about the security there for now. I have some skills in python. The link you’ve sent would be a straight solution, but quick research shows that library “requests” doesn’t work with IronPython ;<

Yes, of course that’s a solution. I’m here for a more sophisticated result though ;p I thought that it would be great added value for a community which has an internet-accessible platform with project data.

Agree wholeheartedly!

Just wanted to point out the workaround if you were in a rush as it’s likely going to take some time to produce that setup as the various security methods require a series of steps which are complicated by IronPython’s inability to work with the method I sent over.

You would need to submit a web request with authorization tokens included. That node in Dynamo doesn’t support that. I think @Radu_Gidei1 might have some nodes in his package that can provide help with that.

@Radu_Gidei1 any comments?

Anyway thank you for the answer, I appreciate that :slight_smile:

Thank you for your participation @Konrad_K_Sobon . Here’s what I’ve achieved so far. It looks like a simple python line can bring a similar result to the “Web Request” node mentioned before:

And this is the code in the python block:

from System.Net import WebClient
content = WebClient().DownloadString(IN[0])

If you are willing to investigate on your own using Python then this might be a good place to start: http://docs.python-requests.org/en/master/user/authentication/

That’s the problem. According to my research and understanding this library “Requests” is not supported in IronPython for some reasons (some other libraries inside it) :frowning:

I’ll try to follow the commands somehow.

What about this: http://www.ironpython.info/index.php?title=Fetching_a_Page_with_Basic_Authentication

OK guys. New day, fresh mind :smiley:
PROBLEM SOLVED
Thank you @Konrad_K_Sobon for the link, it made me look at its content once again!
I found the answer elsewhere though (from the source mentioned in your link). Here is my working ironpython code.
1 input as String
1 output as String

import clr
from System import *
from System.IO import *
from System.Net import *
dataEnteringNode = IN
response=[]
req = HttpWebRequest.Create(IN[0])  #THE LINK IS AN INPUT AS STRING
req.Method = "POST"
req.Credentials = NetworkCredential("USERNAME", "PASSWORD") #INSERT YOUR OWN
req.ContentType = "text/xml; charset=\"UTF-8\"";
req.UserAgent = "IronPython"
reqstm = req.GetRequestStream()
rsp = req.GetRponse();
try:
    response=StreamReader(rsp.GetResponseStream()).ReadToEnd() #THE OUTPUT 
finally:
    rsp.Close()
OUT = response

Great day! :smiley: