Hey! Did you set up an Application Password? You won’t be able to use your regular user credentials. I remember running into exactly the same issue back when I had to set this up myself
Hi @bartv, we got the credentials from the Application Manager. We created two and none of them is working :/. The result is the same, that’s why we modified the .htaccess without results also.
What is the ‘Application Manager’? Did you follow the steps in the documentation I linked to? You should see this ‘Application Passwords’ section in the user profile of the user:
We are testing in a fresh WordPress. The admin user is the one who created the Application Password. We even created two WordPress with the same results. Also, I’m not sure if you can add any configuration to the application password, or am I wrong? Thanks.
I built a Python script and used the same configuration and the error is exactly the same. Using the script, I’m sure I’m using the Application Password. I’m wondering what I should modify since it’s quite odd, I have tried two WordPress instances, and modified the .htconfig and the result is the same.
Python example:
import requests
import json
# WordPress REST API endpoint for creating a post
url = 'https://MY_WORDPRESS_URL/wp-json/wp/v2/posts'
# Application password credentials
username = 'N8N'
password = 'MY_PASSWORD'
# Content of the post
post_data = {
'title': 'Your Post Title',
'content': 'Your post content here.',
'status': 'publish' # Set to 'draft' if you want to save it as a draft
}
# Headers
headers = {
'Content-Type': 'application/json'
}
# Authentication
auth = (username, password)
# Send POST request to create the post
response = requests.post(url, headers=headers, auth=auth, data=json.dumps(post_data))
# Check if the request was successful
if response.status_code == 201:
try:
response_json = response.json()
print('Post created successfully!')
print('Post ID:', response_json['id'])
except json.decoder.JSONDecodeError:
print('Response is not in JSON format.')
print('Response content:', response.content)
else:
print('Failed to create post. Status code:', response.status_code)
print('Error message:', response.content)
It seems your request reaches the API, so I’m pretty sure your .htaccess files are in order. Did you try creating a separate user with only Editor access, not admin?
Looking online a few people have suggested updating the .htaccess, The downside here is while we know the n8n application configuring Wordpress and Apache is outside of our scope so you may need to reach out to the Wordpress communiyt.
From what I can see though the examples provided don’t include the line that contains REMOTE_USER so I would remove that line and see if it helps.