下面是我使用的Python脚本:
import requests
from requests.auth import HTTPBasicAuth
url = 'https://my-phenomenal-website.com/blog/wp-json/wp/v2/posts'
data = {
'title': 'TEST POST 1.1',
'content': 'My outstanding content would go RIGHT HERE',
'status': 'publish'
}
# Replace 'your_username' with the WordPress username
# Replace 'your_application_password' with the application password you created
auth = HTTPBasicAuth('USERNAME IS HERE', 'PASSWORD GOES HERE')
response = requests.post(url, json=data, auth=auth)
if response.status_code == 201:
print("Post published successfully.")
else:
print("Failed to publish post:", response.content)
字符串
我尝试了管理员用户名,以及另一个用户名,使用我为每个用户创建的应用程序密码.没有运气.响应如下:
Failed to publish post: b'<head><title>Not Acceptable!</title></head><body><h1>Not Acceptable!</h1><p>An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.</p></body></html>'
型
尝试修改.htaccess文件,无论是在根域,以及/博客子域,以禁用国防部的安全,因为许多建议来解决这个问题。没有运气。仍然得到相同的错误。
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
型
其他的想法,我可以如何解决这个问题?
1条答案
按热度按时间s6fujrry1#
我花了几个小时试图解决这个问题,以下是对我有效的方法:
字符串