ciphercipher1
Power Member
- Jul 26, 2022
- 530
- 181
Hello guys so I am trying to build an auto uploader that will send HTML content and make it a post
However I am struggling to establish connection with the site. I am providing correct credentials but i still get 401 error. This is my python code
site_url = 'https://sharmaharda.000webhostapp.com/wp-json/wp/v2/'
#authentication part
wordpress_user = "admin"
wordpress_password =
wordpress_credentials = wordpress_user + ':' + wordpress_password
wordpress_token = base64.b64encode(wordpress_credentials.encode())
wordpress_header = {'Authorization': 'Basic' + wordpress_token.decode('utf-8')}
response = requests.get(site_url + 'posts' , verify=False)
if response.status_code == 200:
data = response.json()
print("Connection successful")
for post in data:
print("Title: ", post['title']['rendered'])
else:
print("Connection failed with status code:", response.status_code)
I have added the following to my .htaaccess file :
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
Please take a look and point me in the right direction.
However I am struggling to establish connection with the site. I am providing correct credentials but i still get 401 error. This is my python code
site_url = 'https://sharmaharda.000webhostapp.com/wp-json/wp/v2/'
#authentication part
wordpress_user = "admin"
wordpress_password =
wordpress_credentials = wordpress_user + ':' + wordpress_password
wordpress_token = base64.b64encode(wordpress_credentials.encode())
wordpress_header = {'Authorization': 'Basic' + wordpress_token.decode('utf-8')}
response = requests.get(site_url + 'posts' , verify=False)
if response.status_code == 200:
data = response.json()
print("Connection successful")
for post in data:
print("Title: ", post['title']['rendered'])
else:
print("Connection failed with status code:", response.status_code)
I have added the following to my .htaaccess file :
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
Please take a look and point me in the right direction.
Last edited by a moderator: