JSON API Error – You need to login with a user that has ‘edit_posts’ capacity

I’m building an app on angular and ionic, I’m trying to access my WordPress and create new post.

  1. I’ve generated auth cookie using JSON API User plugin (https://wordpress.org/plugins/json-api/)
  2. I’ve got a valid nonce to create posts.
  3. I’m using all the right parameter to create new post:

    Read More

    $http.post(domain+’/posts/create_post?nonce=’+nonce.nonce+’&title=’+title+’&content=’+content+’&status=’+status+’&author=’+author)

But when I’ve tried to insert new post i get this massage:
“Error: You need to login with a user that has ‘edit_posts’ capacity”

i’ve that i need to add the cookie parameter to the header request, but i don’t understand how.

Please help me to solve this 🙂

Related posts

Leave a Reply

2 comments

  1. This is about the user’s role, not the the auth cookie. The auth cookie would login the user, but their roles and capabilities are stored in the database. There are many ways to change the user’s role, including going into the Admin Dashboard as as admin, clicking Users, the user’s name, and selecting “Editor” [or whatever is appropriate] in the drop down menu.

  2. For complete details, see https://wordpress.org/support/topic/error-you-need-to-login-with-a-user-that-has-edit_posts-capacity.

    But just in case you are having issues with cookie:

    Cookie need to be added to the headers like this:

    Header:Cookie
    Value:<cookie_name>=<cookie>
    

    Also, if you are testing via Postman app from chrome, make sure to enable sending restricted headers (since “Cookie” is a restricted header, for more info see https://www.getpostman.com/docs/requests)