I’m trying to create a new post using cUrl on my WordPress 4.3.1 site with below plugins:
I’ve added below code to my htaccess.conf file, because this thread told me so:
<IfModule !php5_module>
Define USE_PHP_FPM
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Type in command line:
curl --data-binary "@updated-post.json" -H "Content-Type: application/javascript" --user "my_admin_user_name":"my_admin_password" http://www.mysite.nu/wp-json/wp/v2/posts
Contents of updated-post.json:
{
"title": "Hello Updated World!",
"content_raw": "<p>Howdy updated content.</p>",
"date": "2013-04-01T14:00:00+10:00"
}
Error code:
[{"code":"rest_forbidden","message":"You don't have permission to do this.","data":{"status":403}}]
The GET request does work. Some help would be much appreciated!
I found that the problem is in the Basic Auth plugin. WP-API guys recommend using their own plugin and this solution works for me.
Run
git clone https://github.com/WP-API/Basic-Auth.git
Go to your WordPress admin dashboard, plugins page. JSON Basic Authentication should be in the list. Activate it.
Now creating a record via POST request should work.