Alok Jain
Alok Jain

Reputation: 57

WordPress JSON API ( User Creation fails with 404 )

I am new to WordPress. I have installed WordPress and the plugin wp-json api user.

I used the following API to get the user nonce:
http://localhost/wordpress/?json=get_nonce&controller=user&method=register

Then I used the following to create a new user using the following request :

http://localhost/wordpress/api/user/register/?username=john&[email protected]&nonce=89a3935cdc&display_name=John

I am getting 404 in reponse.

Upvotes: 0

Views: 571

Answers (2)

Emm Jk
Emm Jk

Reputation: 91

Make sure you have checked "anyone ca register" from wordpress admin dashboard . Then go to settings > Json Api at the bottom there is a sample link that should be used for Json Api request , you may have redefined the api value and you are not passing the correct and current api value in your request .

Upvotes: 0

Alok Jain
Alok Jain

Reputation: 57

I modified the nginx conf as below :
1) I added the try_files 
location /wordpress/ {
        index  index.php index.html index.htm;
try_files $uri $uri/ /wordpress/index.php?$args;
    }

    location ~.php {
    include /usr/local/etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
2) Added the perma links in the wordpress : Custom perma links
/api/

Now it works fine.

Upvotes: 0

Related Questions