How to call a Web Service from Python with athentication

72
0
09-18-2019 07:27 AM
JoseSanchez
Occasional Contributor III

Hello everyone,

I am able to call a  HTTP web service from Python using urllib, urllib2.

But now I need to add authentication adding the UserID and Password in order to call the another service.

This is the existing code:

import arcpy, urllib, urllib2,

url = r'https://wwww.example.com/GISAddress/Check.asmx/VerifyAddress'
values = {'myAddress' : '100 SW 10 street'}

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
t = ET.fromstring(the_page)

Thank you

0 Kudos
0 Replies