You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I m trying to make a post request using urllib.request and urllib.parse. I am using HTTPBasic Auth which is not right because I dont know what exactly to use for username and password in base64 so my Oracle Eloqua would understand it
import urllib.parse
import urllib.request
import base64
from requests.auth import HTTPBasicAuth
url = 'https://secure.p03.eloqua.com/API/REST/1.0/assets/contact/segment'
values = {
"name":"NewRestContactSegment"
}
data = urllib.parse.urlencode(values)
data = data.encode('UTF-8') # data should be bytes
req = urllib.request.Request(url, data, headers={"content-type":"application/json"}, auth=HTTPBasicAuth('companyname\xxx.xxx', 'xxxxx@123'))
resp = urllib.request.urlopen(req)
responseD = resp.read()
print (responseD)
The text was updated successfully, but these errors were encountered:
Windows: 10
Python: 3.5
I m trying to make a post request using urllib.request and urllib.parse. I am using HTTPBasic Auth which is not right because I dont know what exactly to use for username and password in base64 so my Oracle Eloqua would understand it
import urllib.parse
import urllib.request
import base64
from requests.auth import HTTPBasicAuth
url = 'https://secure.p03.eloqua.com/API/REST/1.0/assets/contact/segment'
values = {
"name":"NewRestContactSegment"
}
data = urllib.parse.urlencode(values)
data = data.encode('UTF-8') # data should be bytes
req = urllib.request.Request(url, data, headers={"content-type":"application/json"}, auth=HTTPBasicAuth('companyname\xxx.xxx', 'xxxxx@123'))
resp = urllib.request.urlopen(req)
responseD = resp.read()
print (responseD)
The text was updated successfully, but these errors were encountered: